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 Ken Hoying <ke...@yahoo.com> on 2003/10/13 16:39:52 UTC

Custom Appender Close() method

I have a custom appender that allows for the buffering
of messages.  However, the messages left in the buffer
when the application finishes are not gettign logged. 
It appears that the close() method is not getting
called.

Any ideas or help would be greatly appreciated.

Thanks,
Ken

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Problem with multiple appenders.

Posted by Sudarshan Krishnaprasad <sk...@cait.org>.
Hi,
The log4j.properties file is as shown below. I have 2 appenders set and 
wish to log the different levels to different places.

log4j.properties

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.R.URL=jdbc:mysql://localhost/test
log4j.appender.R.user=test
log4j.appender.R.password=test
log4j.appender.R.sql=INSERT INTO logTable 
(timestamp,priority,filename,msg) VALUES ('%d', '%p', '%c', '%m')

log4j.rootLogger=ALL, stdout
log4j.logger.database=ERROR, R

The problem I am having is that all the messages are getting logged at 
the console but none of them are getting logged to the database.
If I change the file a little bit and set the root logger to log at 
both the places like:

log4j.rootLogger=ALL, stdout, R

Now all the messages are logged in both the places. Could anyone please 
tell me if the above methods for having multiple loggers is correct.

Regards,
Sudarshan.



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


RE: Custom Appender Close() method

Posted by Ken Hoying <ke...@yahoo.com>.
I reviewed the API documentation and it appears that
the secret here is to call the LogManager.shutdown()
static method.  

Thanks,
Ken

--- Thomas Muller <tt...@online.no> wrote:
> Ken,
> 
> I'm not sure if you can rely on the close method of
> all appenders are being
> closed upon shutdown. You can try to add a
> shutdown-hook that manually
> conducts this for your partiular appender (see
> java.lang.Runtime.addShutdownHook), but read the
> documentation carefully.
> 
> --
> 
> Thomas
> 
> 
> |  -----Original Message-----
> |  From: Ken Hoying [mailto:ken_hoying@yahoo.com]
> |  Sent: 13 October 2003 15:40
> |  To: log4j-user@jakarta.apache.org
> |  Subject: Custom Appender Close() method
> |
> |
> |  I have a custom appender that allows for the
> buffering
> |  of messages.  However, the messages left in the
> buffer
> |  when the application finishes are not gettign
> logged.
> |  It appears that the close() method is not getting
> |  called.
> |
> |  Any ideas or help would be greatly appreciated.
> |
> |  Thanks,
> |  Ken
> |
> |  __________________________________
> |  Do you Yahoo!?
> |  The New Yahoo! Shopping - with improved product
> search
> |  http://shopping.yahoo.com
> |
> | 
>
---------------------------------------------------------------------
> |  To unsubscribe, e-mail:
> log4j-user-unsubscribe@jakarta.apache.org
> |  For additional commands, e-mail:
> log4j-user-help@jakarta.apache.org
> |
> |
> 
> 
> 
>
*************************************************************************
> Copyright ERA Technology Ltd. 2003. (www.era.co.uk).
> All rights reserved. 
> The information supplied in this Commercial
> Communication should be treated
> in confidence.
> No liability whatsoever is accepted for any loss or
> damage 
> suffered as a result of accessing this message or
> any attachments.
> 
>
________________________________________________________________________
> This email has been scanned for all viruses by the
> MessageLabs Email
> Security System. For more information on a proactive
> email security
> service working around the clock, around the globe,
> visit
> http://www.messagelabs.com
>
________________________________________________________________________
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> log4j-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


RE: Custom Appender Close() method

Posted by Thomas Muller <tt...@online.no>.
Ken,

I'm not sure if you can rely on the close method of all appenders are being
closed upon shutdown. You can try to add a shutdown-hook that manually
conducts this for your partiular appender (see
java.lang.Runtime.addShutdownHook), but read the documentation carefully.

--

Thomas


|  -----Original Message-----
|  From: Ken Hoying [mailto:ken_hoying@yahoo.com]
|  Sent: 13 October 2003 15:40
|  To: log4j-user@jakarta.apache.org
|  Subject: Custom Appender Close() method
|
|
|  I have a custom appender that allows for the buffering
|  of messages.  However, the messages left in the buffer
|  when the application finishes are not gettign logged.
|  It appears that the close() method is not getting
|  called.
|
|  Any ideas or help would be greatly appreciated.
|
|  Thanks,
|  Ken
|
|  __________________________________
|  Do you Yahoo!?
|  The New Yahoo! Shopping - with improved product search
|  http://shopping.yahoo.com
|
|  ---------------------------------------------------------------------
|  To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
|  For additional commands, e-mail: log4j-user-help@jakarta.apache.org
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2003. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________

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