You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Sebastian Ho <se...@bii.a-star.edu.sg> on 2004/06/01 09:34:01 UTC

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


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: how to log to different files

Posted by praveen <pr...@yahoo.com>.
set the additivity of logger to false either in properties file or in the code.

properties file:
log4j.logger.xyzlogger.additivity=false

code:
logger.setAdditivity(false);

all the best.
praveen.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ENVIRONNEMENT VARIABLE in log4j.properties

Posted by Jacob Kjome <ho...@visi.com>.
At 03:22 PM 6/1/2004 +0200, you wrote:
>Hi,
>
>I have a small question for Log4j community, how can I do to include an 
>environnement
>variable into my log4j.properties
>
>For exemple, I'd'like to use the $JONAS_BASE variable in order to set the 
>path of my
>log file.

Set a system property at runtime and refer to it as ${JONAS_BASE}.  Note 
that this does not correspond to an environment variable.  It has to be set 
as a Java system property.  You could do this...

java -DJONAS_BASE=/my/path/to/jonas DummyRunJonasClass


Jake



>thanks for your answer.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


ENVIRONNEMENT VARIABLE in log4j.properties

Posted by Jean Charles Jabouille <JE...@BULL.NET>.
Hi,

I have a small question for Log4j community, how can I do to include an environnement
variable into my log4j.properties

For exemple, I'd'like to use the $JONAS_BASE variable in order to set the path of my
log file.


thanks for your answer.


Re: how to log to different files

Posted by Jacob Kjome <ho...@visi.com>.
You are on the right track.  Now you just have to set additivity to "false" 
for each named logger that you don't want to inherit from the root 
logger.  Can't remember the syntax for that in properties files, though.  I 
never use them.  Hopefully someone else can provide the syntax.

Jake

At 03:34 PM 6/1/2004 +0800, you wrote:
>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
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: how to log to different files

Posted by Sebastian Ho <se...@bii.a-star.edu.sg>.
Hi

As requested, this is the entire config file and some output fragments,
as well as a behaviour i discovered recently..

Thanks in advance.

=========================================================================
This is present in application.log before any of the classes using
search.log are called. search.log is empty.
=========================================================================

2004-06-04 06:04:46,038 [main]  INFO CatCrawler:<init> - Application
started.
2004-06-04 06:04:47,402 [main] DEBUG IndexSitesInterface:getSites -
/home/sebastianh/.catcrawler/indexsites.xml
2004-06-04 06:04:47,592 [main]  INFO CatCrawler:initLF - The current
look and feel is Metal

=========================================================================
Once search.log classes are activated, the previous content in
application.log mysteriously disappeared, both the log files now
contains exactly the same output as shown here.
=========================================================================

2004-06-04 06:05:09,796 [AWT-EventQueue-0] DEBUG CatCrawler:setHomePage
- home button clicked []
2004-06-04 06:05:12,805 [AWT-EventQueue-0] DEBUG CatCrawler:startThread
- Thread started
2004-06-04 06:05:12,806 [Thread-3] DEBUG IndexSitesInterface:getSites -
/home/sebastianh/.catcrawler/indexsites.xml
2004-06-04 06:05:12,944 [Thread-3]  INFO CrawlSearchProcess:run -
Starting with 4 sites to process.

========================================================================
log4j.properties
========================================================================

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

# Direct log messages to stdout 
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.additivity.default=false
log4j.additivity.sg.edu.astar.bii.catcrawler.ui.CrawlSearchProcess =
false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.WebCrawler = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.HTMLFilter = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.IndexHTML = false;

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

# Enable log4j internal logging to see how log4j is reading
configuration files
log4j.debug=false



On Fri, 2004-06-04 at 08:03, Douglas WF Acheson wrote:
> Would it be possible to see the full config file and code snipet to see
> exactly what is going on.  Or try mine and see if it works.
> 
> dwfa 
> 
> -----Original Message-----
> From: Sebastian Ho [mailto:sebastianh@bii.a-star.edu.sg] 
> Sent: June 2, 2004 9:38 PM
> To: Log4J Users List
> Subject: RE: how to log to different files
> 
> Hi
> 
> I have added the following lines but it still doesn't work.
> 
> 
> log4j.additivity.sg.edu.astar.bii.catcrawler.ui.CrawlSearchProcess = false;
> log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.WebCrawler = false;
> log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.HTMLFilter = false;
> log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.IndexHTML = false;
> 
> Sebastian
> 
> 
> On Wed, 2004-06-02 at 07:27, Douglas WF Acheson wrote:
> > 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:sebastianh@bii.a-star.edu.sg]
> > Sent: June 1, 2004 3:34 AM
> > To: log4j-user@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
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> > 
> > 
> > ______________________________________________________________________
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: how to log to different files

Posted by Douglas WF Acheson <dw...@dwfa.ca>.
Would it be possible to see the full config file and code snipet to see
exactly what is going on.  Or try mine and see if it works.

dwfa 

-----Original Message-----
From: Sebastian Ho [mailto:sebastianh@bii.a-star.edu.sg] 
Sent: June 2, 2004 9:38 PM
To: Log4J Users List
Subject: RE: how to log to different files

Hi

I have added the following lines but it still doesn't work.


log4j.additivity.sg.edu.astar.bii.catcrawler.ui.CrawlSearchProcess = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.WebCrawler = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.HTMLFilter = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.IndexHTML = false;

Sebastian


On Wed, 2004-06-02 at 07:27, Douglas WF Acheson wrote:
> 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:sebastianh@bii.a-star.edu.sg]
> Sent: June 1, 2004 3:34 AM
> To: log4j-user@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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> ______________________________________________________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: how to log to different files

Posted by Sebastian Ho <se...@bii.a-star.edu.sg>.
Hi

I have added the following lines but it still doesn't work.


log4j.additivity.sg.edu.astar.bii.catcrawler.ui.CrawlSearchProcess =
false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.WebCrawler = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.HTMLFilter = false;
log4j.additivity.sg.edu.astar.bii.catcrawler.crawler.IndexHTML = false;

Sebastian


On Wed, 2004-06-02 at 07:27, Douglas WF Acheson wrote:
> 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:sebastianh@bii.a-star.edu.sg] 
> Sent: June 1, 2004 3:34 AM
> To: log4j-user@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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> ______________________________________________________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: how to log to different files

Posted by Douglas WF Acheson <dw...@dwfa.ca>.
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:sebastianh@bii.a-star.edu.sg] 
Sent: June 1, 2004 3:34 AM
To: log4j-user@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


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org