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 "Damian ONeill [AePONA]" <Da...@aepona.com> on 2003/06/21 20:55:30 UTC

org.apache.log4j.spi.LoggingEvent


Can you please suggest the best way to clone a LoggingEvent?

Thanks in advance,
Damian ONeill.

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


Re: org.apache.log4j.spi.LoggingEvent

Posted by Ceki Gülcü <ce...@qos.ch>.
Damian,

The LoggingEvent class is intended to be immutable.

At 02:25 PM 6/24/2003 +0100, you wrote:
>Thanks Ceki, but I cannot guarantee that adapter subclasses will not 
>modify the LoggingEvent, as we are allowing 3rd Parties (not under our 
>control) the ability to create Adapter subclasses.

--
Ceki  For log4j documentation consider "The complete log4j manual"
       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp 


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


Re: org.apache.log4j.spi.LoggingEvent

Posted by "Damian ONeill [AePONA]" <da...@aepona.com>.
Thanks Ceki, but I cannot guarantee that adapter subclasses will not 
modify the LoggingEvent, as we are allowing 3rd Parties (not under our 
control) the ability to create Adapter subclasses.

Ceki Gülcü wrote:

> At 09:18 AM 6/24/2003 +0100, you wrote:
>
>> We are using log4j for logging events to an event manager via the 
>> socket appender.  The event manager is running in a separate process 
>> and uses a object input stream to build the received LoggingEvent.  
>> The Event Manager has a internal event chain that event sinks can 
>> register with to receive the logging event.  The event sinks extend 
>> an adapter class that provides support for handling the event.  The 
>> adapter implements runnable and has a wait queue.  Each adapter is 
>> kicked off as a separate thread where the run method dequeues the 
>> event and passes it to an abstract method that the base class must 
>> implement.
>>
>> I wish to clone the LoggingEvent so that each adapter sub class 
>> (separate thread) has its own copy of the event to do with as it 
>> wishes. We invoke the Event Sinks dynamically so that the framework 
>> can be extended by third parties, therefore I cannot guarantee or 
>> impose restrictions on what the adapter class may do with the event.
>
>
> If your adapters do not modify the LoggingEvent than you are all set, 
> even if the adapters are in different thread. You do not have to 
> perform any changes. Cloning will be necessary only if your adapters 
> modify Loggingevent fields.
>
>
>> Damian.
>
>
> -- 
> Ceki  For log4j documentation consider "The complete log4j manual"
>       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

-- 
damian.oneill@aepona.com

Damian O'Neill
Software Engineer
AePONA Ltd,
Interpoint Building,
20-24 York Street,
Belfast,
BT15 1AQ

+44 (0) 2890 275246

http://www.aepona.com




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


Re: org.apache.log4j.spi.LoggingEvent

Posted by Ceki Gülcü <ce...@qos.ch>.
At 09:18 AM 6/24/2003 +0100, you wrote:
>We are using log4j for logging events to an event manager via the socket 
>appender.  The event manager is running in a separate process and uses a 
>object input stream to build the received LoggingEvent.  The Event Manager 
>has a internal event chain that event sinks can register with to receive 
>the logging event.  The event sinks extend an adapter class that provides 
>support for handling the event.  The adapter implements runnable and has a 
>wait queue.  Each adapter is kicked off as a separate thread where the run 
>method dequeues the event and passes it to an abstract method that the 
>base class must implement.
>
>I wish to clone the LoggingEvent so that each adapter sub class (separate 
>thread) has its own copy of the event to do with as it wishes. We invoke 
>the Event Sinks dynamically so that the framework can be extended by third 
>parties, therefore I cannot guarantee or impose restrictions on what the 
>adapter class may do with the event.

If your adapters do not modify the LoggingEvent than you are all set, even 
if the adapters are in different thread. You do not have to perform any 
changes. Cloning will be necessary only if your adapters modify 
Loggingevent fields.


>Damian.

--
Ceki  For log4j documentation consider "The complete log4j manual"
       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp 


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


Accessing multiple log files

Posted by Milind Rao <mi...@bellsouth.net>.
I'm looking at using log4j to do logging in our application.  Multiple clients on different machines will be logging events.  
The Message object in the LoggingEvent class is an instance of a  proprietary Log class that contains a date.  The Log 
class implements ObjectRenderer and contains a Date object.    The events are date based.  Each day will have its own 
log file (This is a requirement).  So far, I could have used log4j almost as is, implementing just the ObjectRenderer.  But 
there is one requirement for which I have to do some specialisation.

For the most part, almost all the logging events will be for the current date, but occasionally, the date object in the 
message could be an earlier date.  If I use FileAppender (or DailyRollingFileAppender) it will append all logs to the 
current log file.  However I need to be able to append the event to a previous day's log file depending on the value of the 
date in the message.

After going through the log4j code, I think I have to subclass FileAppender (or DailyRollingFileAppender) and redefine 
the "append" method to compare the file with the specified date and open the appropriate log file if required.  (If I 
redefine the "subappend" method, the "checkEntryConditions" will have been done for the current date's file).

My questions are

1. To begin with, is this the right approach?

2. Is "append" thread safe?  I believe it is based on the synchronized code block in the "callAppenders"  method of 
Category.  But that's not the black box behaviour.  Can I make assumptions based on existing code?  I don't think so.  
But I wonder about performance if I have to set up synchronized blocks in my subclass.

3. Should I call "activateOptions" after setting the file name?  I expected to see a call to "activateOptions" in the "rollover" 
method of the DailyRollingFileAppender class, but it seems it's getting called from somewhere else.  Where?

4. The "setFile" method closes the file.  So if I have interleaved logging events for different dates, this will be rather 
inefficient.  I could redefine "reset" to no-op and close the files (from a list) in a redefined "rollover" method.  Will this 
have some side-effect?  Seems fragile.  Might break in a later version of log4j.






Regards
Milind



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


Re: org.apache.log4j.spi.LoggingEvent

Posted by "Damian ONeill [AePONA]" <da...@aepona.com>.
We are using log4j for logging events to an event manager via the socket 
appender.  The event manager is running in a separate process and uses a 
object input stream to build the received LoggingEvent.  The Event 
Manager has a internal event chain that event sinks can register with to 
receive the logging event.  The event sinks extend an adapter class that 
provides support for handling the event.  The adapter implements 
runnable and has a wait queue.  Each adapter is kicked off as a separate 
thread where the run method dequeues the event and passes it to an 
abstract method that the base class must implement.

I wish to clone the LoggingEvent so that each adapter sub class 
(separate thread) has its own copy of the event to do with as it wishes. 
 We invoke the Event Sinks dynamically so that the framework can be 
extended by third parties, therefore I cannot guarantee or impose 
restrictions on what the adapter class may do with the event.

Since the javadoc does not say whether the LoggingEvent is thread safe, 
the simplest way for me to guarantee no issues is to clone the event 
before I pass it to the adapter sub class.


Hope this helps,
Damian.




Ceki Gülcü wrote:

>
> Damian,
>
> LoggingEvent is not clonable and this has not been a problem this far.
> Can you please explain what you are trying to accomplish by cloning 
> LoggingEvent objects?
>
> At 04:38 PM 6/23/2003 +0000, you wrote:
>
>> Is there anyone on this list that can answer this question? or is the 
>> the developers list more suitable?
>>
>> Thanks.
>>
>> Damian ONeill [AePONA] wrote:
>>
>>> Can you please suggest the best way to clone a LoggingEvent?
>>>
>>> Thanks in advance,
>>> Damian ONeill.
>>>
>>
>> -- 
>> damian.oneill@aepona.com
>>
>> Damian O'Neill
>> Software Engineer
>> AePONA Ltd,
>> Interpoint Building,
>> 20-24 York Street,
>> Belfast,
>> BT15 1AQ
>>
>> +44 (0) 2890 275246
>>
>> http://www.aepona.com
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>>
>
> -- 
> Ceki  For log4j documentation consider "The complete log4j manual"
>       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

-- 
damian.oneill@aepona.com

Damian O'Neill
Software Engineer
AePONA Ltd,
Interpoint Building,
20-24 York Street,
Belfast,
BT15 1AQ

+44 (0) 2890 275246

http://www.aepona.com




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


RE: org.apache.log4j.spi.LoggingEvent

Posted by Scott Heaberlin <he...@yahoo.com>.
I do know that LoggingEvents are serializable... one way (albeit if
there are other mechanisms I'd prefer them) to clone an instance would
be to serialize then deserialize...


-Scott Heaberlin



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


Re: org.apache.log4j.spi.LoggingEvent

Posted by Ceki Gülcü <ce...@qos.ch>.
Damian,

LoggingEvent is not clonable and this has not been a problem this far.
Can you please explain what you are trying to accomplish by cloning 
LoggingEvent objects?

At 04:38 PM 6/23/2003 +0000, you wrote:
>Is there anyone on this list that can answer this question? or is the the 
>developers list more suitable?
>
>Thanks.
>
>Damian ONeill [AePONA] wrote:
>
>>Can you please suggest the best way to clone a LoggingEvent?
>>
>>Thanks in advance,
>>Damian ONeill.
>>
>
>--
>damian.oneill@aepona.com
>
>Damian O'Neill
>Software Engineer
>AePONA Ltd,
>Interpoint Building,
>20-24 York Street,
>Belfast,
>BT15 1AQ
>
>+44 (0) 2890 275246
>
>http://www.aepona.com
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

--
Ceki  For log4j documentation consider "The complete log4j manual"
       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp 


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


Re: org.apache.log4j.spi.LoggingEvent

Posted by "Damian ONeill [AePONA]" <da...@aepona.com>.
Is there anyone on this list that can answer this question? or is the 
the developers list more suitable?

Thanks.

Damian ONeill [AePONA] wrote:

>Can you please suggest the best way to clone a LoggingEvent?
>
>Thanks in advance,
>Damian ONeill.
>  
>

-- 
damian.oneill@aepona.com

Damian O'Neill
Software Engineer
AePONA Ltd,
Interpoint Building,
20-24 York Street,
Belfast,
BT15 1AQ

+44 (0) 2890 275246

http://www.aepona.com




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