dcsimg
More on: Logging to multiple files
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jan_Gifvars
Posted On:   Wednesday, February 26, 2003 06:29 AM

Hello, I will have two loggers logging to different files, but can't get it to work. I have read the thread started 5 of February by sudhakar satrasala and the suggested solution setting logger.setAdditivity(false) but that gives me an error when starting, like; log4j:WARN No appenders could be found for logger (groopi.emailchannel). log4j:WARN Please initialize the log4j system properly. Is there anyone out there who have an example to show? Best regards, Jan Gifvars Please use html tags to format code blocks.    More>>

Hello,



I will have two loggers logging to different files, but can't get it to work. I have read the thread started 5 of February by sudhakar satrasala and the suggested solution setting
logger.setAdditivity(false) but that gives me an error when starting, like;

log4j:WARN No appenders could be found for logger (groopi.emailchannel).

log4j:WARN Please initialize the log4j system properly.


Is there anyone out there who have an example to show?




Best regards,
Jan Gifvars


Please use html tags to format code blocks.

   <<Less

Re: More on: Logging to multiple files

Posted By:   Yang_Yang  
Posted On:   Wednesday, March 5, 2003 07:29 PM


Hi there,

I have exactly the same problem and found the solution by checking their source code. Apparently the short manual does not cover everything :-)

log4j.logger.com=DEBUG,appender1
log4j.logger.com.abc=DEBUG,appender2
log4j.additivity.com.abc=false

With the above setting, logging request from com.abc will only go to appender 2 and not appender 1.

Good luck!

Regards,
Yang Yang

Re: More on: Logging to multiple files

Posted By:   James_Bayer  
Posted On:   Wednesday, February 26, 2003 07:33 AM

i use the property configurator:

PropertyConfigurator.configure( "fullpath to property file here" );



this setup uses 2 files and the console and i have no problems with it:


# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.

# The root category uses the appender called A1 with specified priority of INFO.

log4j.rootCategory=INFO, A1, E, A2

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

############################################################
# E is the RollingFileAppender that outputs to an error log
# file called error.log.
############################################################
log4j.appender.E=org.apache.log4j.FileAppender
log4j.appender.E.File=error.log

# Define a pattern layout for the file.
# For more information on conversion characters (i.e. d,p,t,c,l,m,n)
# please see the PatternLayout class of the Log4j API.

log4j.appender.E.layout=org.apache.log4j.PatternLayout

# The following normally appears on one single line.
log4j.appender.E.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Set the max size of the file
log4j.appender.E.threshold=ERROR

############################################################
# A2 is the FileAppender that outputs to an log
# file called output.log
############################################################
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=output.log

# Define a pattern layout for the file.
# For more information on conversion characters (i.e. d,p,t,c,l,m,n)
# please see the PatternLayout class of the Log4j API.

log4j.appender.A2.layout=org.apache.log4j.PatternLayout

# The following normally appears on one single line.
log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Set the max size of the file
log4j.appender.A2.threshold=INFO
About | Sitemap | Contact