[
https://issues.apache.org/jira/browse/LOG4J2-1832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15897355#comment-15897355
]
vaibhav singh commented on LOG4J2-1832:
---------------------------------------
Ok, after hours of looking at Log4j2 apidocs I realised that I was not
instantiating the LoggerConfig object properly.
Instead of:
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ERROR,
"logger", "com.*", refs, null, config, null);
The loggerConfig object should be created like:
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ERROR,
"logger", "true", refs, null, config, null);
Please note that the fourth param to be passed is "includeLocation", and it has
to be set to "true" for Reflection to kick in and the classname to be printed.
>From the APIdoc:
includeLocation - whether location should be passed downstream
Maybe the documentation for the parameter could be made clearer, but for now, I
think I am satisfied. So, marking this question as Resolved.
> Programmatical Configuration of Log4j2 with RollingFileAppender does not
> honor logging classnames
> -------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-1832
> URL: https://issues.apache.org/jira/browse/LOG4J2-1832
> Project: Log4j 2
> Issue Type: Question
> Components: Configurators
> Affects Versions: 2.7
> Environment: Ubuntu 16.04
> Reporter: vaibhav singh
> Labels: beginner, features
> Fix For: boot-1.0-alpha1
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> I am trying to programmatically configure a Log4j2 logger with a Rolling File
> appender, and am seeing that classnames are not getting printed according to
> the Layouts page(https://logging.apache.org/log4j/2.x/manual/layouts.html)
> Can someone please help me understand why is it that the classname is not
> getting printed? Is it an existing bug with PatternLayout class?
> Test class:
> http://pastebin.com/yBQ7mGPC
> Output:
> http://pastebin.com/cnfnqauz
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]