2

I have a class that is logging things in application log. I wanted to have something special logged to a separate file, so I created an inner class and modified the SpringConfig like this

log4j.logger.xxx.OuterClass.InnerClass=INFO, STALENESS

private static final Log log = LogFactory.getLog(InnerClass.class);

And with appender STALENESS it should write to the new file.

I think this should work, but it didn't. It's still writing in the original file, except that it has an "appender" like: 04 Oct 2016 20:55:40,746 [INFO] (main) xxx.OuterClass$InnerClass: test message

It works when the class is extracted out.

Does anyone have an idea why it's not working? Should it work for inner class or I have to extract the class out?

1 Answer 1

2

I have a similar problem and I use this approach

private final static Logger log = LoggerFactory.getLogger(MyClass.class.getName() + "." + MyInnerClass.class.getSimpleName());

And I configured my log file like this

log4j.logger.xxx.yyy.MyClass.MyInnerClass=DEBUG
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.