Re: Renaming log file

2008-01-28 Thread James A. N. Stauffer
I'm not sure what you want but RollingFileAppender will make files
like what you want.

On Jan 27, 2008 10:52 PM, anoobthomas [EMAIL PROTECTED] wrote:

 Currently I am using Daily Rolling File Appender to generate log files.

 I want to rename my log file from ABC.log2008-1-27 to ABC.log number
 sequence , like ABC.log1,ABC.log2 and so on.

 Should I create a custom appender or are there any appenders that generate
 this format.
 If I have to create a custom appender please let me know how to do it.
 --
 View this message in context: 
 http://www.nabble.com/Renaming-log-file-tp15128382p15128382.html
 Sent from the Log4j - Users mailing list archive at Nabble.com.


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





-- 
James A. N. Staufferhttp://www.geocities.com/stauffer_james/
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]



Re: Renaming log file

2008-01-28 Thread Curt Arnold


On Jan 28, 2008, at 6:47 AM, James A. N. Stauffer wrote:


I'm not sure what you want but RollingFileAppender will make files
like what you want.


If you do need to write custom code, I would recommend writing a  
custom RollingPolicy for the  
org.apache.log4j.rolling.RollingFileAppender (o.a.l.r.RFA) in the  
extras companion (http://logging.apache.org/companions/extras).  The  
o.a.l.r.RFA was designed to support pluggable RollingPolicies which  
provide the strategy for renaming files and TriggeringPolicies which  
provide the strategy for determining when to trigger files.  It seems  
like you might just want to mix the FixedWindowRollingPolicy (which  
provides .1, .2, etc file names) with a TimeBasedTriggeringPolicy.


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



Write a bean to a file

2008-01-28 Thread Tim Nguyen
Hi,

I am a newbie of Log4j. I wonder if anyone has an example or an utility of how 
to write a bean to a file using Log4j. Thank you!




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


Re: Write a bean to a file

2008-01-28 Thread Curt Arnold


On Jan 28, 2008, at 1:24 PM, Tim Nguyen wrote:


Hi,

I am a newbie of Log4j. I wonder if anyone has an example or an  
utility of how to write a bean to a file using Log4j. Thank you!





Not quite sure what you are asking.  You can pass any Object as the  
message parameter.  Unless you register an ObjectRenderer for that  
specific type, then that Object's toString() method will be called to  
get a rendered string for formatting.  If you register an  
ObjectRenderer, then that class will be used to create the text  
representation of the object.



That is:

SomeBean bean = 
logger.info(bean);

is typically equivalent to:

SomeBean bean = 
logger.info(String.toString(bean));

You can specify an class implementing  
org.apache.log4j.or.ObjectRenderer to be used to render a specific  
class by configuring it in the configuration file or  
programmatically.  Programmatically, should look something like:


((org.apache.log4j.or.RendererSupport)  
logger.getRepository()).addRenderer(com.example.MyBean, new  
MyBeanRenderer());


I'm not sure how it would look in a configuration file and can't find  
a ready example, but I'm not going to dig on it unless that is what  
you want to do and nobody else speaks up.


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



RE: Write a bean to a file

2008-01-28 Thread Scott Deboy
There is also the rewriteappender in log4j 1.3 and the
ReflectionRewritePolicy that will allow you to write arbitrary objects
to the file (you don't have to specify which classes to render in the
config file).

http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/
log4j/rewrite/package-summary.html




Scott Deboy
Principal Engineer
COMOTIV SYSTEMS
111 SW Columbia Street Ste. 950
Portland, OR  97201
Office: 503.224.7496
Direct Line: 503.821.6482
Cell: 503.997.1367
Fax: 503.222.0185
[EMAIL PROTECTED]
www.comotivsystems.com


-Original Message-
From: Tim Nguyen [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 28, 2008 1:54 PM
To: Log4J Users List
Subject: Re: Write a bean to a file

Thanks Curt! That's exactly what I am looking for. 

- Original Message 
From: Curt Arnold [EMAIL PROTECTED]
To: Log4J Users List log4j-user@logging.apache.org
Sent: Monday, January 28, 2008 1:34:27 PM
Subject: Re: Write a bean to a file



On 
Jan 
28, 
2008, 
at 
1:24 
PM, 
Tim 
Nguyen 
wrote:

 
Hi,

 
I 
am 
a 
newbie 
of 
Log4j. 
I 
wonder 
if 
anyone 
has 
an 
example 
or 
an  
 
utility 
of 
how 
to 
write 
a 
bean 
to 
a 
file 
using 
Log4j. 
Thank 
you!



Not 
quite 
sure 
what 
you 
are 
asking.  
You 
can 
pass 
any 
Object 
as 
the  
message 
parameter.  
Unless 
you 
register 
an 
ObjectRenderer 
for 
that  
specific 
type, 
then 
that 
Object's 
toString() 
method 
will 
be 
called 
to  
get 
a 
rendered 
string 
for 
formatting.  
If 
you 
register 
an  
ObjectRenderer, 
then 
that 
class 
will 
be 
used 
to 
create 
the 
text  
representation 
of 
the 
object.


That 
is:

SomeBean 
bean 
= 

logger.info(bean);

is 
typically 
equivalent 
to:

SomeBean 
bean 
= 

logger.info(String.toString(bean));

You 
can 
specify 
an 
class 
implementing  
org.apache.log4j.or.ObjectRenderer 
to 
be 
used 
to 
render 
a 
specific  
class 
by 
configuring 
it 
in 
the 
configuration 
file 
or  
programmatically.  
Programmatically, 
should 
look 
something 
like:

((org.apache.log4j.or.RendererSupport)  
logger.getRepository()).addRenderer(com.example.MyBean, 
new  
MyBeanRenderer());

I'm 
not 
sure 
how 
it 
would 
look 
in 
a 
configuration 
file 
and 
can't 
find  
a 
ready 
example, 
but 
I'm 
not 
going 
to 
dig 
on 
it 
unless 
that 
is 
what  
you 
want 
to 
do 
and 
nobody 
else 
speaks 
up.

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







 


Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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