File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Multiple log4j appenders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Multiple log4j appenders" Watch "Multiple log4j appenders" New topic
Author

Multiple log4j appenders

C Weaver
Greenhorn

Joined: Jun 28, 2012
Posts: 6
Is it possible to have different appenders in a log4j.xml file and write to the one I want in the code?

I want to have 2 different loggers, 1 that is the normal application log file where all the debug, info, warn, etc. entries go. Then I want to have a detailed log file where I write details about the j2ee call a client made. We would only go to the second log file if there was a question about the data. I would expect the second file to get large quickly so I was going to make it file size specific with 10 generates or so. It would only store a few days worth of information, but that would be enough.

My other thought is if I can't specify which appender I want the log entry written to, I would create a class that allows me to control it based on the call.

Any thoughts?

Thanks,
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Which version of JBoss AS?

In general, the answer is yes, you can have different appenders, and you can configure the detail appender to limit its size.

To log data to a specific appender, use a logger like this:



JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple log4j appenders