Skip to Content
author's profile photo Former Member
Former Member

Hybris 6 -Log4j2 - custom level

Do we have experience in creating custom log level in Hybris 6?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jul 21, 2016 at 05:57 PM

    Hi Saurabh,

    Short Answer:

     logger.log(Level.forName("OPER", 350), "an operational message");
    


    Long Answer:

    The Log4J2 documentation page, Custom Log Levels, says that this is possible.

    1. Create an extension, loggingutils for the Logging Utils.

    2. Add your extended Logger class to this, with the operational level method.

    3. Add the loggingutils as a Required Extension where you need it.

    Then you can use:

     // ExtLogger is a generated logger wrapper
     import com.mycompany.myproject.ExtLogger;
      
     public class MyService {
         // instead of Logger logger = LogManager.getLogger(MyService.class):
         private static final ExtLogger logger = ExtLogger.create(MyService.class);
      
         public void someMethod() {
             // ...
             logger.operational("your custom OPERATIONAL level");
    

    I hope this helps,
    Luke

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2016 at 06:17 PM
    -1

    I wanted to add one custom level say "operational" logs apart from existing levels(Debug, Trace ) etc

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.