RE: Serialization problem?

2005-07-14 Thread Caroline Wood

Ah, that makes sense now, thanks. Would the best strategy for passing an
object via the message be to override the toString() method to marshal the
object to an xml string? Or is there a better way of approaching this?

Many thanks,
Caroline.

-Original Message-
From: Tom Drake [mailto:[EMAIL PROTECTED] 
Sent: 11 July 2005 19:24
To: 'Log4J Users List'
Subject: RE: Serialization problem?

This is the defined behaviour. You may configure an ObjectRenderer to gain
finer control over how your message is converted into a string, but Log4j
will turn this message into string form prior to sending across a socket, or
to a JMS queue.

-Original Message-
From: Caroline Wood [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 11, 2005 1:38 AM
To: 'log4j-user@logging.apache.org'
Subject: FW: Serialization problem?



Any ideas? Thanks. :-)

 

Hi folks,

 

Can anyone work out what I'm doing wrong?

I've written an appender that extends JMS appender, and also a MDB to
process the messages.

The logging message is a simple data container class called MonitorMessage.

 

However, the data object does not seem to be (de)serializing properly and is
arriving in the MDB as a String. The Data class does implement serializable!

 

The junit test looks like this:

---

public void testSimpleMonAppender() {

MonitorMessage msg = new MonitorMessage( new Integer( 1 ) );

LOG.info( msg );

  }

---

The relevant code in the MDB is:

---

public void onMessage( Message msg ) {

LOGGER.debug( Got a monitoring message! );

 

ObjectMessage om;

LoggingEvent event;

MonitorMessage message;

if( msg instanceof ObjectMessage ) {

  om = (ObjectMessage)msg;

  try {

// Get the logging event from the message

event = (LoggingEvent)om.getObject();

 

// Check the message type

LOGGER.debug(The message is an instance of  +
event.getMessage().getClass());

LOGGER.debug(At level  + event.getLevel().toString());

if(event.getMessage() instanceof MonitorMessage) {

  message = (MonitorMessage)event.getMessage();

  LOGGER.debug(The id is  + message.getMessageIdentifier());

}

else if(event.getMessage() instanceof java.lang.String) {

  LOGGER.debug(The string is  + event.getMessage());

}

else {

  LOGGER.debug(event.getMessage().toString());

}

  }

  catch( javax.jms.JMSException ex ) {

LOGGER.error( JMS exception when getting the logging event : , ex
);

  }

 

}

else {

  try {

LOGGER.warn( Warning - the message type is  + msg.getJMSType() +
, the expected type was ObjectMessage );

  }

  catch( javax.jms.JMSException ex ) {

LOGGER.error( JMS exception when getting the JMS message type: ,
ex );

  }

}

 

LOGGER.debug( Processed monitoring message! );

  }

}

---

The debug from the MDB looks like this:

---

) - Processed monitoring message!

2005-07-06 11:34:57,268 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:65)

 - Got a monitoring message!

2005-07-06 11:34:57,270 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:77)

 - The message is an instance of class java.lang.String

2005-07-06 11:34:57,271 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:78)

 - At level INFO

2005-07-06 11:34:57,271 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:84)

 - The string is [ messageIdentifier = 1

2005-07-06 11:34:57,272 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:104

) - Processed monitoring message!

---

What am I doing wrong?!

Tia,

Caroline.




This is an email from the CPP Group Plc, Holgate Park, York, YO26 4GA;
telephone 01904 544500. This message may contain information that is
confidential. If you are not the intended recipient, you may not peruse,
use, disseminate, distribute or copy this message. If you have received this
message in error, please notify the sender immediately by email, facsimile
or telephone and either return or destroy the original message. The CPP
Group Plc accepts no responsibility for any changes made to this message
after it has been sent by the original author.  This email has been scanned
for all viruses by the MessageLabs Email Security System.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


This is an email from the CPP Group Plc, Holgate Park, York, YO26 4GA; 
telephone 01904 544500.
This message may contain information that is confidential. If you are not the 
intended recipient,
you may not peruse, use, disseminate, distribute or copy this message. If you 
have received this
message in error, please notify the sender 

Appenders at different log levels for a single logger

2005-07-14 Thread Rob van der Leek
Hi list,

How can I define appenders at different log levels for the same logger?  
For instance, what if I want to route all ERROR-level messages to an 
error logfile and all other messages to a different logfile.

I'd hoped something like this would be possible:

log4j.rootLogger=DEBUG, logfile
log4j.rootLogger=ERROR, errorlog

log4j.appender.logfile=org.apache.log4j.RollingFileAppender 
log4j.appender.logfile.File=logfile.log 
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 
log4j.appender.logfile.layout.ConversionPattern=%d [%t:%L] %-6p %c - %m%n 

log4j.appender.errorlog=org.apache.log4j.RollingFileAppender 
log4j.appender.errorlog.File=error.log 
log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout 
log4j.appender.errorlog.layout.ConversionPattern=%d [%t:%L] %-6p %c - 
%m%n 

Unfortunately it seems that this configuration only routes ERROR-level 
messages to the errorlog and discards all other messages.

Best regards,
-- 
Rob van der Leek| rob(at)ricardis(dot)tudelft(dot)nl

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Appenders at different log levels for a single logger

2005-07-14 Thread Philip Kaplan
Your second rootLogger entry is overriding your first.  Keep the root
logger set at debug and place both appenders there...and then set the
threshold values on each of the loggers to DEBUG and ERROR
respectively.

log4j.appender.logfile.Threshold=DEBUG
log4j.appender.errorlog.Threshold=ERROR


pK.





On 7/14/05, Rob van der Leek [EMAIL PROTECTED] wrote:
 Hi list,
 
 How can I define appenders at different log levels for the same logger?
 For instance, what if I want to route all ERROR-level messages to an
 error logfile and all other messages to a different logfile.
 
 I'd hoped something like this would be possible:
 
 log4j.rootLogger=DEBUG, logfile
 log4j.rootLogger=ERROR, errorlog
 
 log4j.appender.logfile=org.apache.log4j.RollingFileAppender
 log4j.appender.logfile.File=logfile.log
 log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
 log4j.appender.logfile.layout.ConversionPattern=%d [%t:%L] %-6p %c - %m%n
 
 log4j.appender.errorlog=org.apache.log4j.RollingFileAppender
 log4j.appender.errorlog.File=error.log
 log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout
 log4j.appender.errorlog.layout.ConversionPattern=%d [%t:%L] %-6p %c -
 %m%n
 
 Unfortunately it seems that this configuration only routes ERROR-level
 messages to the errorlog and discards all other messages.
 
 Best regards,
 --
 Rob van der Leek| rob(at)ricardis(dot)tudelft(dot)nl
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Appenders at different log levels for a single logger

2005-07-14 Thread Rob van der Leek
On Thu (Jul 14) at 09:34, Philip Kaplan wrote:
 Your second rootLogger entry is overriding your first.  Keep the root
 logger set at debug and place both appenders there...and then set the
 threshold values on each of the loggers to DEBUG and ERROR
 respectively.
 
 log4j.appender.logfile.Threshold=DEBUG
 log4j.appender.errorlog.Threshold=ERROR

Thanks Philip! I suspected I was overriding and not extending the 
logger, these attributes work fine.

Regards, Rob

-- 
Rob van der Leek| rob(at)ricardis(dot)tudelft(dot)nl
Ricardishof 71-A|  http://www.robvanderleek.info
2614 JE Delft, The Netherlands
+31 (0)6 155 244 60

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reloading the config file

2005-07-14 Thread log4jusers . ml . trace
The log4j Configurator class has a method
configureAndWatch(String configFilename, long delay)
which can check that a config file has changed and, if so, reload it (delay 
being the reload interval).

This is a very convenient method. However, it seems that this method can only 
be applied to local files, not to URLs, and that it won't reload a config 
file located on a remote server. Am I correct?

  --Fred Mora

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Reloading the config file

2005-07-14 Thread Mark Womack
You are correct.  It is only a file watcher, not a url watcher. v1.3 will
have a much richer set of functionality that can watch a file, url, or a
socket for updated configuration data and it will also support any
Configurator.

-Mark

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 14, 2005 8:20 AM
 To: log4j-user@logging.apache.org
 Subject: Reloading the config file
 
 The log4j Configurator class has a method
 configureAndWatch(String configFilename, long delay)
 which can check that a config file has changed and, if so, reload it
 (delay
 being the reload interval).
 
 This is a very convenient method. However, it seems that this method can
 only
 be applied to local files, not to URLs, and that it won't reload a config
 file located on a remote server. Am I correct?
 
   --Fred Mora
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



V1.2.8: RollingFileAppender missing log file numbers?

2005-07-14 Thread Karr, David
We're seeing an odd problem with the RollingFileAppender, perhaps when
we're pushing it pretty hard.  At the end of the day sometimes we look
at the directory where the log files are stored, and it appears that
some of the log file numbers are missing.  It isn't just that it wrote
it out with the wrong name, that content is really missing.  The gaps in
log entry times indicate those missing file names would have contained
the missing content.

Is there anything that could explain this?  Is there something we can do
to mitigate the problem?

We're using the Log4J that's embedded in WebLogic 8.1, so it would be
awkward (impossible?) to upgrade to a newer release to solve this
problem.  It's concievable we could use a different appender, however,
if it didn't depend on a newer release of log4j.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SMTPAppender help needed

2005-07-14 Thread Rusty Wright
I'm trying to use SMTPAppender but it's not sending me the email.  I 
figured out that I need to add Sun's jaf.jar and activation.jar, so now 
it runs without any error.


This is a standalone program that's packaged as a jar file.  My smtp 
server is postfix.  The CONS and FILE appenders are working.  The 
program is using Commons net to do an ftp file upload.


I'm running it with the command

  /usr/java/bin/java -Dlog4j.debug -jar /usr/local/cars/bin/cars.jar

Following the config file is the debug output.

Thanks.

Here's my log4j.xml config file:

?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;
appender name=CONS class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%M %m%n /
/layout
/appender

!-- param entries must come before layout entry!?  --
appender name=FILE class=org.apache.log4j.RollingFileAppender
param name=File value=/var/tmp/cars.log /
param name=MaxFileSize value=300kb /
param name=MaxBackupIndex value=9 /
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%p: %d [%C %M] %m%n /
/layout
/appender

!-- param entries must come before layout entry!?  --
appender name=MAIL class=org.apache.log4j.net.SMTPAppender
param name=SMTPHost value=localhost /
param name=From value=CARS-Uploader /
param name=To value=rusty /
param name=Subject value=CARS upload mail log /
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%p: %d [%C %M] %m%n /
/layout
/appender

!-- example of how to change the level and appender--
!-- for a specific class.  --
logger name=props.PropsBase
level value=warn /
appender-ref ref=FILE /
/logger

root
level value=debug /
appender-ref ref=CONS /
appender-ref ref=FILE /
appender-ref ref=MAIL /
/root
/log4j:configuration

Here's the output:

log4j: Trying to find [properties/log4j.xml] using context classloader 
[EMAIL PROTECTED]
log4j: Trying to find [log4j.xml] using context classloader 
[EMAIL PROTECTED]
log4j: Trying to find [log4j.xml] using 
[EMAIL PROTECTED] class loader.

log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
[EMAIL PROTECTED]
log4j: Trying to find [log4j.properties] using 
[EMAIL PROTECTED] class loader.
log4j: Trying to find [log4j.properties] using 
ClassLoader.getSystemResource().

log4j: Could not find resource: [null].
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: 
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

log4j: debug attribute= null.
log4j: Ignoring debug attribute.
log4j: Threshold =null.
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [props.PropsBase] additivity to [true].
log4j: Level value for props.PropsBase is  [warn].
log4j: props.PropsBase level set to WARN
log4j: Class name: [org.apache.log4j.RollingFileAppender]
log4j: Setting property [file] to [/var/tmp/cars.log].
log4j: Setting property [maxFileSize] to [300kb].
log4j: Setting property [maxBackupIndex] to [9].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%p: %d [%C %M] %m%n].
log4j: setFile called: /var/tmp/cars.log, true
log4j: setFile ended
log4j: Adding appender named [FILE] to category [props.PropsBase].
log4j: Level value for root is  [debug].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%M %m%n].
log4j: Adding appender named [CONS] to category [root].
log4j: Adding appender named [FILE] to category [root].
log4j: Class name: [org.apache.log4j.net.SMTPAppender]
log4j: Setting property [SMTPHost] to [localhost].
log4j: Setting property [from] to [CARS-Uploader].
log4j: Setting property [to] to [rusty].
log4j: Setting property [subject] to [CARS upload mail log].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%p: %d [%C %M] %m%n].
log4j: Adding appender named [MAIL] to category [root].
main start getting entries from db
main finished getting entries from db
main uploadName: 'rbs.q.carcyin.d050713.test1'
connect 220-FTPD1 IBM FTP CS V1R4 at ironwood.Berkeley.EDU, 23:36:07 on 
2005-07-13.

connect 220 Connection will close if idle for more than 5 minutes.
connect 230 WSS0RCW is logged on.  Working directory is WSS0RCW..
sendCarsData 200 Representation type is Ascii NonPrint
sendCarsData 

Re: Log4j config problem

2005-07-14 Thread James Stauffer
Set additivity to false for your program's logger.

On 7/14/05, Dariusz [EMAIL PROTECTED] wrote:
 Hi,
 
 I am migrating an application from JDK logger to Log4j 1.2.9 (using
 Tomcat 5.0.28) and almost got it to work, except for one remaining
 issue.  Hopefully someone will be able to give me some tips on how to
 solve it.
 What I want to have is a separate log file for all Tomcat output
 (log4j.log containing info about starting/stopping service,
 initializing, etc.) and two separate log files for the application
 output: an Error.log file which will let me quickly see any errors that
 might have occurred, and another file, All.log containing all debug
 info.
 Both Error.log and All.log are OK.  The problem is with 'log4j.log'
 file.  While it correctly shows all relevant Tomcat log messages, it
 also includes all application debug messages (duplicating All.log
 file).  Because of all the included debug messages it is very difficult
 to spot any Tomcat errors that might have occurred.  I can suppress the
 debug messages in log4j.log by disabling the appender for All.log, but I
 would like to keep All.log and have log4j.log only display server info.
 Any help would be greatly appreciated.
 
 Thanks.
 --Dariusz.
 
 
 Here is my log4j.properties file:
 
 log4j.rootLogger=ERROR, R
 log4j.disable=INFO
 
 log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.R.DatePattern='.'-MM-dd
 log4j.appender.R.File=../logs/log4j.log
 log4j.appender.R.layout=org.apache.log4j.PatternLayout
 log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
 log4j.logger.org.apache=INFO
 
 
 AppLog.properties
 
 #
 log4j.logger.AppLogger = ALL, DebugAppender, ErrorAppender
 log4j.appender.DebugAppender = org.apache.log4j.RollingFileAppender
 log4j.appender.DebugAppender.MaxFileSize = 1000KB
 log4j.appender.DebugAppender.MaxBackupIndex = 1000
 log4j.appender.DebugAppender.Append = true
 log4j.appender.DebugAppender.Threshold = DEBUG
 log4j.appender.DebugAppender.File = ../webapps/mdinfo/logs/All.log
 log4j.appender.DebugAppender.layout = org.apache.log4j.PatternLayout
 log4j.appender.DebugAppender.layout.ConversionPattern=%d{MM/dd/yy
 HH:mm}%m\n
 #
 log4j.appender.ErrorAppender = org.apache.log4j.RollingFileAppender
 log4j.appender.ErrorAppender.MaxFileSize = 1000KB
 log4j.appender.ErrorAppender.MaxBackupIndex = 1000
 log4j.appender.ErrorAppender.Append = true
 log4j.appender.ErrorAppender.Threshold = ERROR
 log4j.appender.ErrorAppender.File = ../webapps/mdinfo/logs/Errors.log
 log4j.appender.ErrorAppender.layout = org.apache.log4j.PatternLayout
 log4j.appender.ErrorAppender.layout.ConversionPattern=%d{MM/dd/yy
 HH:mm}%p %m\n
 
 
 I also have a Logger.java class, which reads the 'AppLog.properties'
 file and gets an org.apache.log4j.Logger.  This logger is then used to
 call various log() methods.  Param 'fileName' is set to
 AppLog.properties (see above).
 
  // ---
  private synchronized void createJavaLogger(String fileName)
  {
   Properties props = new Properties();
 
   try
   {
ClassLoader myLoader = Logger.class.getClassLoader();
URL propertiesFileURL = myLoader.getResource(fileName);
FileInputStream fis = new
 FileInputStream(propertiesFileURL.getFile());
props.load(fis);
 
PropertyConfigurator.configure(props);
javaLogger1 = org.apache.log4j.Logger.getLogger(AppLogger);
 
   }catch (Exception e) {
System.out.println(Error setting-up Logger and/or handlers. +
 e.getMessage());
e.printStackTrace();
javaLogger1 = org.apache.log4j.Logger.getRootLogger();
   }
  }
 
 Thanks again.
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Log4J: System.out and System.err

2005-07-14 Thread Mike Wannamaker
Is there a way to tell log4J to capture System.out or System.err?  Also it
looks like log4j at certain levels of logging also logs to the
System.err/System.out can anyone confirm this?  Possibly through something
called a QuietWriter?

TIA
--ekiM

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Log4J: System.out and System.err

2005-07-14 Thread Javier Gonzalez
Don't know about capturing System.out or System.err, but the 
ConsoleAppender can be created with the property Target set to
System.out or System.err for logging to the desired stream

-- 
Javier Gonzalez Nicolini

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SMTPAppender

2005-07-14 Thread Rusty Wright
I went and looked in the list archives and someone pointed out that 
SMTPAppender is set up to only log error level stuff.  The default 
TriggeringEventEvaluator it's using only triggers on error level.  So I 
wrote my own TriggeringEventEvaluator that always returns true and now 
it logs everything, but each call to log.whatever() generates a separate 
email.


The usefulness of SMTPAppender is eluding me.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Log4J: System.out and System.err

2005-07-14 Thread Mike Wannamaker
I don't want to send to, I want to capture.  We have applications that are
writing to System.out and System.err and I want to capture those and log
them to a Logger.

What I've done is this:

private static void setupLoggerOutputStreams()
{
ComponentLogger logger = new ComponentLogger(null);
PrintStream err = new LoggerStream(logger, true);   //
true - because we want the err stream to always be on
PrintStream out = new LoggerStream(logger, false);  //
false - because we want normal output to be controled by the filters
System.setErr(err);
System.setOut(out);
}

Although I still get some exceptions etc being logged to the console window?

--ekiM

-Original Message-
From: Javier Gonzalez [mailto:[EMAIL PROTECTED] 
Sent: July 14, 2005 3:26 PM
To: Log4J Users List
Subject: Re: Log4J: System.out and System.err

Don't know about capturing System.out or System.err, but the 
ConsoleAppender can be created with the property Target set to
System.out or System.err for logging to the desired stream

-- 
Javier Gonzalez Nicolini

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: SMTPAppender

2005-07-14 Thread Paul Smith
It's useful when you want to know via email when a particular event  
happened (the triggering event, usually an ERROR of some sort) along  
with context logging lines before that triggering event to help you  
understand how the code came to that trigger point (hence a buffer  
size for this appender)


The SMTPAppender keeps hold of the last X events in the buffer until  
the trigger point, then sends the buffer with the trigger event via  
email to you.


What is the use case you want to send logging emails to yourself?

Paul

On 15/07/2005, at 5:47 AM, Rusty Wright wrote:

I went and looked in the list archives and someone pointed out that  
SMTPAppender is set up to only log error level stuff.  The default  
TriggeringEventEvaluator it's using only triggers on error level.   
So I wrote my own TriggeringEventEvaluator that always returns true  
and now it logs everything, but each call to log.whatever()  
generates a separate email.


The usefulness of SMTPAppender is eluding me.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Log4j config problem

2005-07-14 Thread Dariusz
Thanks James.  It worked like a charm.  Can't believe I spent so much 
time trying to figure it out and you solved it in one sentence. 
Thanks again.

--Dariusz.

James Stauffer wrote:


Set additivity to false for your program's logger.

On 7/14/05, Dariusz [EMAIL PROTECTED] wrote:
 


Hi,

   I am migrating an application from JDK logger to Log4j 1.2.9 (using
Tomcat 5.0.28) and almost got it to work, except for one remaining
issue.  Hopefully someone will be able to give me some tips on how to
solve it.
What I want to have is a separate log file for all Tomcat output
(log4j.log containing info about starting/stopping service,
initializing, etc.) and two separate log files for the application
output: an Error.log file which will let me quickly see any errors that
might have occurred, and another file, All.log containing all debug
info.
   Both Error.log and All.log are OK.  The problem is with 'log4j.log'
file.  While it correctly shows all relevant Tomcat log messages, it
also includes all application debug messages (duplicating All.log
file).  Because of all the included debug messages it is very difficult
to spot any Tomcat errors that might have occurred.  I can suppress the
debug messages in log4j.log by disabling the appender for All.log, but I
would like to keep All.log and have log4j.log only display server info.
Any help would be greatly appreciated.

Thanks.
--Dariusz.


Here is my log4j.properties file:

log4j.rootLogger=ERROR, R
log4j.disable=INFO

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'-MM-dd
log4j.appender.R.File=../logs/log4j.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.logger.org.apache=INFO


AppLog.properties

#
log4j.logger.AppLogger = ALL, DebugAppender, ErrorAppender
log4j.appender.DebugAppender = org.apache.log4j.RollingFileAppender
log4j.appender.DebugAppender.MaxFileSize = 1000KB
log4j.appender.DebugAppender.MaxBackupIndex = 1000
log4j.appender.DebugAppender.Append = true
log4j.appender.DebugAppender.Threshold = DEBUG
log4j.appender.DebugAppender.File = ../webapps/mdinfo/logs/All.log
log4j.appender.DebugAppender.layout = org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%d{MM/dd/yy
HH:mm}%m\n
#
log4j.appender.ErrorAppender = org.apache.log4j.RollingFileAppender
log4j.appender.ErrorAppender.MaxFileSize = 1000KB
log4j.appender.ErrorAppender.MaxBackupIndex = 1000
log4j.appender.ErrorAppender.Append = true
log4j.appender.ErrorAppender.Threshold = ERROR
log4j.appender.ErrorAppender.File = ../webapps/mdinfo/logs/Errors.log
log4j.appender.ErrorAppender.layout = org.apache.log4j.PatternLayout
log4j.appender.ErrorAppender.layout.ConversionPattern=%d{MM/dd/yy
HH:mm}%p %m\n


I also have a Logger.java class, which reads the 'AppLog.properties'
file and gets an org.apache.log4j.Logger.  This logger is then used to
call various log() methods.  Param 'fileName' is set to
AppLog.properties (see above).

// ---
private synchronized void createJavaLogger(String fileName)
{
 Properties props = new Properties();

 try
 {
  ClassLoader myLoader = Logger.class.getClassLoader();
  URL propertiesFileURL = myLoader.getResource(fileName);
  FileInputStream fis = new
FileInputStream(propertiesFileURL.getFile());
  props.load(fis);

  PropertyConfigurator.configure(props);
  javaLogger1 = org.apache.log4j.Logger.getLogger(AppLogger);

 }catch (Exception e) {
  System.out.println(Error setting-up Logger and/or handlers. +
e.getMessage());
  e.printStackTrace();
  javaLogger1 = org.apache.log4j.Logger.getRootLogger();
 }
}

Thanks again.





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


   




 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]