

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
9 messages in org.apache.logging.log4j-userRE: how to log to different files| From | Sent On | Attachments |
|---|---|---|
| Sebastian Ho | Jun 1, 2004 12:33 am | |
| Jacob Kjome | Jun 1, 2004 6:06 am | |
| Jean Charles Jabouille | Jun 1, 2004 6:21 am | |
| Jacob Kjome | Jun 1, 2004 6:29 am | |
| Douglas WF Acheson | Jun 1, 2004 4:27 pm | .xml |
| Sebastian Ho | Jun 2, 2004 6:37 pm | |
| Douglas WF Acheson | Jun 3, 2004 5:02 pm | |
| Sebastian Ho | Jun 3, 2004 11:20 pm | |
| praveen | Sep 2, 2005 9:40 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE: how to log to different files | Actions... |
|---|---|---|
| From: | Douglas WF Acheson (dw...@dwfa.ca) | |
| Date: | Jun 1, 2004 4:27:09 pm | |
| List: | org.apache.logging.log4j-user | |
| Attachments: | ![]() log4j.xml - 2k | |
This is what I have and it seems to work.
The config file.
<?xml version = "1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration debug = "false" xmlns:log4j = 'http://jakarta.apache.org/log4j/'>
<!-- Define the debug log async appender --> <appender name = "debug.async" class = "org.apache.log4j.AsyncAppender"> <param name = "BufferSize" value = "10240"/> <param name = "LocationInfo" value = "true"/> <appender-ref ref = "debug.file"/> </appender>
<!-- Define the debug log worker appender --> <appender name = "debug.file" class = "org.apache.log4j.FileAppender"> <param name = "Append" value = "true"/> <param name = "File" value = "debug.log"/> <layout class = "org.apache.log4j.PatternLayout"> <param name = "ConversionPattern" value = "[%-d{MM/dd/yyyy HH:mm:ss.SSS}][%l - %t] %m%n"/> </layout> </appender>
<!-- ********************************************************************** -->
<!-- Define the error log async appender --> <appender name = "error.async" class = "org.apache.log4j.AsyncAppender"> <param name = "BufferSize" value = "10240"/> <param name = "LocationInfo" value = "true"/> <appender-ref ref = "error.file"/> </appender>
<!-- Define the error log worker appender --> <appender name = "error.file" class = "org.apache.log4j.FileAppender"> <param name = "Append" value = "true"/> <param name = "File" value = "error.log"/> <layout class = "org.apache.log4j.PatternLayout"> <param name = "ConversionPattern" value = "[%-d{MM/dd/yyyy}][%l - %t] %m%n"/> </layout> </appender>
<!-- ********************************************************************** -->
<!-- Define the debug log logger --> <logger name = "debug" additivity = "false"> <appender-ref ref = "debug.async"/> </logger>
<!-- Define the error log logger --> <logger name = "error" additivity = "false"> <appender-ref ref = "error.async"/> </logger>
<!-- ********************************************************************** -->
<root> <level value = "debug"/> <!-- appender-ref ref = "debug.async"/ --> </root> </log4j:configuration>
And the code snipet:
DOMConfigurator.configure(args[0]) ; Logger.getLogger("error") ; Logger.getLogger("debug") ;
I have include the two file for full reference ....
dwfa
-----Original Message----- From: Sebastian Ho [mailto:seba...@bii.a-star.edu.sg] Sent: June 1, 2004 3:34 AM To: log4...@logging.apache.org Subject: how to log to different files
Hi
I wish to have output from classes to go into a log file and some other classes (from the same packages) into another log file. I have the following log4j.properties configuration but it doesn't work.
From the config, there are 4 fours that I wish to go into 'searchfile'
and all the other classes to log to 'file'.
What this produces is both files (searchfile and file) are created and contains exactly the same logs. All logs (including those from the 4 classes) goes into both the files.
This is what I have in my Java files.
static Logger logger = Logger.getLogger(CatCrawler.class); PropertyConfigurator.configure(path_to_log4j.properties_file);
============================================================================ ===== log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=${user.home}/.catcrawler/log/application.log log4j.appender.file.threshold=debug log4j.appender.file.append=false log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d [%t] %5p %c{1}:%M - %m%n
log4j.appender.searchfile=org.apache.log4j.FileAppender log4j.appender.searchfile.File=${user.home}/.catcrawler/log/search.log log4j.appender.searchfile.threshold=debug log4j.appender.searchfile.append=false log4j.appender.searchfile.layout=org.apache.log4j.PatternLayout log4j.appender.searchfile.layout.ConversionPattern=%d [%t] %5p %c{1}:%M - %m%n
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.threshold=debug log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d [%t] %5p %c{1}:%M - %m%n
log4j.rootLogger=DEBUG, file, stdout
log4j.logger.sg.edu.astar.bii.catcrawler.ui.CrawlSearchProcess = DEBUG, searchfile log4j.logger.sg.edu.astar.bii.catcrawler.crawler.WebCrawler = DEBUG, searchfile log4j.logger.sg.edu.astar.bii.catcrawler.crawler.HTMLFilter = DEBUG, searchfile log4j.logger.sg.edu.astar.bii.catcrawler.crawler.IndexHTML = DEBUG, searchfile
============================================================================ =====
Thanks
Sebastian Ho BII








.xml