How to log message from the parent class

2007-03-16 Thread wolverine my

Hi!

I have the following Java classes:


abstract class AbstractAnimal {

 Logger logger = Logger.getLogger(AbstractAnimal.class);

 protected void something() {
   logger.debug("animal is doing something");
 }
}

class Dog extends AbstractAnimal {

 Logger logger = Logger.getLogger(Dog.class);

 protected void anything() {
   logger.debug("dog is doing anything");
   something();
 }
}

class Cat extends AbstractAnimal {

 Logger logger = Logger.getLogger(Cat.class);

 protected void nothing() {
   logger.debug("cat is doing nothing");
   something();
 }
}


Note that the classes are in three difference packages
and the log4j.properties looks like the following:


log4j.logger.Dog=ALL, R1
log4j.appender.R1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R1.File=dog.log

log4j.logger.Dog=ALL, R2
log4j.appender.R2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R2.File=cat.log


The above configuration only logs "dog is doing anything" to dog.log
and "cat is doing nothing" to cat.log.

How can I configure Log4j so that it will also log "animal is doing
something" in both log files?

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



AW: How to log message from the parent class

2007-03-16 Thread Wyss Patrick
add the following to you log4j.properties:
"
log4j.rootCategory=ALL, R1, R2
"
to log all other events to both appenders/files
or
"
log4j.logger.AbstractAnimal =ALL, R1, R2
"
to log only the events of AbstractAnimal to both appenders/files

btw: 
> Note that the classes are in three difference packages

i think currently all your classes are in the same (default)package
otherwise the configuration for the loggers would have to be different...

cheers
patrick

> -Ursprüngliche Nachricht-
> Von: wolverine my [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 16. März 2007 10:30
> An: Log4J Users List
> Betreff: How to log message from the parent class
> 
> 
> Hi!
> 
> I have the following Java classes:
> 
> 
> abstract class AbstractAnimal {
> 
>   Logger logger = Logger.getLogger(AbstractAnimal.class);
> 
>   protected void something() {
> logger.debug("animal is doing something");
>   }
> }
> 
> class Dog extends AbstractAnimal {
> 
>   Logger logger = Logger.getLogger(Dog.class);
> 
>   protected void anything() {
> logger.debug("dog is doing anything");
> something();
>   }
> }
> 
> class Cat extends AbstractAnimal {
> 
>   Logger logger = Logger.getLogger(Cat.class);
> 
>   protected void nothing() {
> logger.debug("cat is doing nothing");
> something();
>   }
> }
> 
> 
> Note that the classes are in three difference packages
> and the log4j.properties looks like the following:
> 
> 
> log4j.logger.Dog=ALL, R1
> log4j.appender.R1=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.R1.File=dog.log
> 
> log4j.logger.Dog=ALL, R2
> log4j.appender.R2=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.R2.File=cat.log
> 
> 
> The above configuration only logs "dog is doing anything" to dog.log
> and "cat is doing nothing" to cat.log.
> 
> How can I configure Log4j so that it will also log "animal is doing
> something" in both log files?
> 
> -
> 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: many File Appenders on same file

2007-03-16 Thread Kate Ward

In the Unix world, it usually works for small amounts of data as the file
system will manage the simultaneous access itself. There are no guarantees
though on ordering, whether the full message will be logged (if it is a long
message), or whether it will work at all. On Windows, I'm doubting it will
work due to windows not liking more than one process to write to a file at a
time, but this depends on how the file is actually opened in log4j (and
ultimately in Java), and I'm no expert here.

The same type of problem exists when mail servers must accept large amounts
of mail for a single mailbox. To handle things correctly, locking is used
(whether that be file system locking, creating a lock file, etc), and then
things like race conditions must be handled, deadlocks, etc. as the locking
process might die leaving the lock. A much more complicated problem than it
seems on the surface.

Back to your question, it will probably work on Unix (success depends upon
the Unix variant), and probably not so well on Windows. In any case, if you
want your code to be truly portable and safe, it is probably better to not
do it. Not exactly the type of thing you want to rely upon, especially when
it might change when you upgrade your OS.

- kate

On 3/5/07, James Stauffer <[EMAIL PROTECTED]> wrote:


Generally having more than 1 process write to a file is bad.  You
could have both processes send the logs to a socket appender and have
1 socket server receive them and write them to the 1 file.

On 3/5/07, Cheung, Quinn <[EMAIL PROTECTED]> wrote:
> Is there any danger in having more than 1 process (or more than 1
thread)  use File Appenders that are configured to write to the same
file?  If it can be done safely, are there any performance issues?
>
> Thanks
> Squid
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
James 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]





--
Kate Ward <[EMAIL PROTECTED]>


large amounts of 0 characters at beginning of log

2007-03-16 Thread Jeff Drew

I'm having a problem in one installation where approximately 8 Mb of 0x00
appear at the start of the log file.  Then the file contains typical log
output.  A typical RollingFileAppender writes to this file.
MaxFileSize=10KB and MaxBackupIndex=3.

Since this log is what I use for application diagnosis, I'm struggling to
identify what initiates this problem.

Does this sound similar to known mis-configurations, problems, etc?  Any
suggestions on how to diagnose this problem?

Thanks


Re: Inconsistancy between logger.XXX("message") and logger.isXXXEnabled()

2007-03-16 Thread James Stauffer

The results you claim are surprising.  I don't expect it to check for
the existence of a logger but I do expect the fact that the effective
level is info would cause isDebugEnabled() to return false.

On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote:

I'm using version 1.2.14

My expectation in using log4j was that a call to logger.isXXXEnabled()
would return true only in the case that a call to logger.XXX("some
message") would result in the message being written to some appender.
However, it appears that the existence of an appender has no bearing the
Enabled call.

For example, I have this simple configuration:






  


  

  

  


  



Using this configuration, and this program (based on log4j's examples):


package chapter3;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

public class BugApp3 {
//final static Logger logger = Logger.getLogger(BugApp3.class);
final static Logger logger = Logger.getLogger("chapter3.BugApp3");

  public static void main(String[] args) {
DOMConfigurator.configure(args[0]);

logger.info("Entering application.");

//debug is not enabled
logger.debug("Debug is enabled.");

if (logger.isDebugEnabled()) {
logger.info("isDebugEnabled() returns true!");
}

logger.info("Exiting application.");
  }
}

I see the following output:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
3[main] INFO  chapter3.BugApp3  - Exiting application.

However, if I set the root level to "debug" instead, then I get this
output instead:

% java chapter3.BugApp3 bug0.xml
1[main] INFO  chapter3.BugApp3  - Entering application.
3[main] INFO  chapter3.BugApp3  - Exiting application.

Since the goal of an isXXXEnabled() statement is to avoid doing
unnecessary work in the case where it will not result in actual debug
output, it seems unfortunate that it does not take into account the
existence of an appender.

Is this behavior intentional?

-John





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





--
James 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: Inconsistancy between logger.XXX("message") and logger.isXXXEnabled()

2007-03-16 Thread James Stauffer

I just did a test with 1.2.8 and got different results.  Please retest.

In sps.wfds.biz.glacier.JDocOptions:
   logger.info("logger.isDebugEnabled()=" + logger.isDebugEnabled());

 
 
   
   
 

INFO 27:56.449 sps.wfds.biz.glacier.JDocOptions   logger.isDebugEnabled()=false


On 3/16/07, James Stauffer <[EMAIL PROTECTED]> wrote:

The results you claim are surprising.  I don't expect it to check for
the existence of a logger but I do expect the fact that the effective
level is info would cause isDebugEnabled() to return false.

On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote:
> I'm using version 1.2.14
>
> My expectation in using log4j was that a call to logger.isXXXEnabled()
> would return true only in the case that a call to logger.XXX("some
> message") would result in the message being written to some appender.
> However, it appears that the existence of an appender has no bearing the
> Enabled call.
>
> For example, I have this simple configuration:
>
> 
> 
>
> 
>
>   
> 
> 
>   
> 
>   
>
>   
> 
> 
>   
> 
>
>
> Using this configuration, and this program (based on log4j's examples):
>
>
> package chapter3;
>
> import org.apache.log4j.Logger;
> import org.apache.log4j.xml.DOMConfigurator;
>
> public class BugApp3 {
> //final static Logger logger = Logger.getLogger(BugApp3.class);
> final static Logger logger = Logger.getLogger("chapter3.BugApp3");
>
>   public static void main(String[] args) {
> DOMConfigurator.configure(args[0]);
>
> logger.info("Entering application.");
>
> //debug is not enabled
> logger.debug("Debug is enabled.");
>
> if (logger.isDebugEnabled()) {
> logger.info("isDebugEnabled() returns true!");
> }
>
> logger.info("Exiting application.");
>   }
> }
>
> I see the following output:
>
> % java chapter3.BugApp3 bug0.xml
> 0[main] INFO  chapter3.BugApp3  - Entering application.
> 2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
> 3[main] INFO  chapter3.BugApp3  - Exiting application.
>
> However, if I set the root level to "debug" instead, then I get this
> output instead:
>
> % java chapter3.BugApp3 bug0.xml
> 1[main] INFO  chapter3.BugApp3  - Entering application.
> 3[main] INFO  chapter3.BugApp3  - Exiting application.
>
> Since the goal of an isXXXEnabled() statement is to avoid doing
> unnecessary work in the case where it will not result in actual debug
> output, it seems unfortunate that it does not take into account the
> existence of an appender.
>
> Is this behavior intentional?
>
> -John
>
>
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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




--
James 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: Logger not found exception

2007-03-16 Thread Jacob Kjome
Quoting Kailash Chandra <[EMAIL PROTECTED]>:

> I am using the log4j.2.8.jar in my ear file Log jar file is place at my lib
> folder at ear level

Do you mean "APP-INF/lib"?  If it's just in "lib", Weblogic doesn't see that. 
It must be the former.

> I have also set the class-path option of meta-inf file
> of jar file used in ear file to log4j.2.8.jar file's path

I never tried using the manifest classpath with EAR files in Weblogic.  I
suggest using the APP-INF/lib feature.  It works exactly like WEB-INF/lib does
for webapps.  All .jar files in APP-INF/lib will be included in the classpath
and made visible to all webapps and EJBs deployed within the EAR.

> But when I deploy
> the app on Weblogic 8.1 server it throws an exception that DOMconfigurator
> class not found exception
>

Let me know if using APP-INF/lib doesn't solve your problem.  It should.

Jake

>
> --
> DISCLAIMER
>
> This email and any files transmitted with it are confidential and are solely
> for the use of the individual or entity to which it is addressed. Any use,
> distribution, copying or disclosure by any other person is strictly
> prohibited. If you receive this transmission in error, please notify the
> sender by reply email and then destroy the message. Opinions, conclusions and
> other information in this message that do not relate to official business of
> the company shall be understood to be neither given nor endorsed by NIIT Ltd.
> or NIIT Technologies Ltd. Any information contained in this email, when
> addressed to Clients is subject to the terms and conditions in governing
> client contract.
>
>
>
> -
> 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]



DailyRollingFileAppender help needed please

2007-03-16 Thread Andrew Marlow
Hello guys,

I am new to log4j so please bear with me. I am writing a program in java
that used to be written in C++. The C++ program used a home-grown
logger. I am trying to use log4j to do the logging. The homegrown logger
used to write 4 logfiles per day; the files were considered as watches
of a 6 hour duration (->0600, 0600->1200, 1200->1800 and
1800->2400). It looks to me like I might be able to use
DailyRollingFileAppender to do a similar job.

The trouble is, I do not know what DatePattern to use to get the
rollover happening every six hours starting at midnight. The watches are
absolute times, they are NOT six hours from the start of execution.

Here is my appender:

  








The name of the file that gets created contains a literal '-MM-dd-a'
rather than the actual date/time I expected. What am I doing wrong
please?

Finally, the program gives a warning at startup:

log4j:WARN No such property [maxLogs] in
org.apache.log4j.DailingRollingFileAppender.

What does this mean please? How can I make this problem go away?

Regards,

Andrew Marlow

There is an emerald here the size of a plover's egg!
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please  http://www.expita.com/nomime.html


**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software 
viruses, but we advise you to carry out your own virus checks on any attachment 
to this message. We cannot accept liability for any loss or damage caused by 
software viruses. "
*** 












 


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



Re: DailyRollingFileAppender help needed please

2007-03-16 Thread James Stauffer

There are no included appenders that can do that.  You could easily
write your own appender to do that or use DailyRollingFileAppender to
roll every hour and then have 6 files for each "watch".

On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:

Hello guys,

I am new to log4j so please bear with me. I am writing a program in java
that used to be written in C++. The C++ program used a home-grown
logger. I am trying to use log4j to do the logging. The homegrown logger
used to write 4 logfiles per day; the files were considered as watches
of a 6 hour duration (->0600, 0600->1200, 1200->1800 and
1800->2400). It looks to me like I might be able to use
DailyRollingFileAppender to do a similar job.

The trouble is, I do not know what DatePattern to use to get the
rollover happening every six hours starting at midnight. The watches are
absolute times, they are NOT six hours from the start of execution.

Here is my appender:

  








The name of the file that gets created contains a literal '-MM-dd-a'
rather than the actual date/time I expected. What am I doing wrong
please?

Finally, the program gives a warning at startup:

log4j:WARN No such property [maxLogs] in
org.apache.log4j.DailingRollingFileAppender.

What does this mean please? How can I make this problem go away?

Regards,

Andrew Marlow

There is an emerald here the size of a plover's egg!
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please  http://www.expita.com/nomime.html


**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software viruses, but 
we advise you to carry out your own virus checks on any attachment to this message. 
We cannot accept liability for any loss or damage caused by software viruses. "
***


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





--
James 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: DailyRollingFileAppender help needed please

2007-03-16 Thread Andrew Marlow
James Stauffer wrote:
> There are no included appenders that can do that.  You could
> easily write your own appender to do that or use
> DailyRollingFileAppender to roll every hour and then have 6
> files for each "watch".

ok, but ...

The name of the file that gets created contains a literal '-MM-dd-a'
rather than the actual date/time I expected. What am I doing wrong 
please?
Finally, the program gives a warning at startup:
log4j:WARN No such property [maxLogs] in 
org.apache.log4j.DailingRollingFileAppender.
What does this mean please? How can I make this problem go away?



> 
> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
>> Hello guys,
>> 
>> I am new to log4j so please bear with me. I am writing a program in
>> java that used to be written in C++. The C++ program used a
>> home-grown logger. I am trying to use log4j to do the logging. The
>> homegrown logger used to write 4 logfiles per day; the files were
>> considered as watches of a 6 hour duration (->0600, 0600->1200,
>> 1200->1800 and 1800->2400). It looks to me like I might be able to
>> use DailyRollingFileAppender to do a similar job.



**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software 
viruses, but we advise you to carry out your own virus checks on any attachment 
to this message. We cannot accept liability for any loss or damage caused by 
software viruses. "
*** 












 


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



Re: DailyRollingFileAppender help needed please

2007-03-16 Thread James Stauffer

maxLogs isn't a value of that appender in 1.2.  You may be thinking of
RollingFileAppender or 1.3.

Don't put the pattern in the File value.
  


On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:

James Stauffer wrote:
> There are no included appenders that can do that.  You could
> easily write your own appender to do that or use
> DailyRollingFileAppender to roll every hour and then have 6
> files for each "watch".

ok, but ...

The name of the file that gets created contains a literal '-MM-dd-a'
rather than the actual date/time I expected. What am I doing wrong
please?
Finally, the program gives a warning at startup:
log4j:WARN No such property [maxLogs] in
org.apache.log4j.DailingRollingFileAppender.
What does this mean please? How can I make this problem go away?



>
> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
>> Hello guys,
>>
>> I am new to log4j so please bear with me. I am writing a program in
>> java that used to be written in C++. The C++ program used a
>> home-grown logger. I am trying to use log4j to do the logging. The
>> homegrown logger used to write 4 logfiles per day; the files were
>> considered as watches of a 6 hour duration (->0600, 0600->1200,
>> 1200->1800 and 1800->2400). It looks to me like I might be able to
>> use DailyRollingFileAppender to do a similar job.



**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software viruses, but 
we advise you to carry out your own virus checks on any attachment to this message. 
We cannot accept liability for any loss or damage caused by software viruses. "
***


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





--
James 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: DailyRollingFileAppender help needed please

2007-03-16 Thread Andrew Marlow
James Stauffer wrote:
> maxLogs isn't a value of that appender in 1.2.  You may be
> thinking of RollingFileAppender or 1.3.

The question is, "what is log4j thinking of?". After all, it is log4j that says:

>> log4j:WARN No such property [maxLogs] in
>> org.apache.log4j.DailyRollingFileAppender.

> 
> Don't put the pattern in the File value.
>   value="logs/LogFile.log"/>

Hmm. Removing the pattern certainly makes the pattern bit disappear from the 
filename. But all I am left with is literally what is in the value. So now my 
logfile is called LogFile.log! How can I get the date/time into the filename 
please? I expected it to appear in the format -MM-dd, i.e. modelled after 
the DatePattern.

BTW, I really appreciate this rapid feedback. Thanks very much!

-Andrew

> 
> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
>> James Stauffer wrote:
>>> There are no included appenders that can do that.  You could easily
>>> write your own appender to do that or use DailyRollingFileAppender
>>> to roll every hour and then have 6 files for each "watch".
>> 
>> ok, but ...
>> 
>> The name of the file that gets created contains a literal
>> '-MM-dd-a' rather than the actual date/time I expected. What am
>> I doing wrong please? Finally, the program gives a warning at
>> startup: 
>> log4j:WARN No such property [maxLogs] in
>> org.apache.log4j.DailingRollingFileAppender.
>> What does this mean please? How can I make this problem go away?
>>> 
>>> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
 Hello guys,
 
 I am new to log4j so please bear with me. I am writing a program in
 java that used to be written in C++. The C++ program used a
 home-grown logger. I am trying to use log4j to do the logging. The
 homegrown logger used to write 4 logfiles per day; the files were
 considered as watches of a 6 hour duration (->0600, 0600->1200,
 1200->1800 and 1800->2400). It looks to me like I might be able to
 use DailyRollingFileAppender to do a similar job.



**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software 
viruses, but we advise you to carry out your own virus checks on any attachment 
to this message. We cannot accept liability for any loss or damage caused by 
software viruses. "
*** 












 


-

Re: DailyRollingFileAppender help needed please

2007-03-16 Thread James Stauffer

That log4j output is telling you that maxLogs isn't a valid property
of DailyRollingFileAppender.

DailyRollingFileAppender only uses the date pattern when it needs to
roll.  The current file is always named exactly the value of the File
property.

From javadocs:

For example, if the File option is set to /foo/bar.log and the
DatePattern set to '.'-MM-dd, on 2001-02-16 at midnight, the
logging file /foo/bar.log will be copied to /foo/bar.log.2001-02-16
and logging for 2001-02-17 will continue in /foo/bar.log until it
rolls over the next day.


On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:

James Stauffer wrote:
> maxLogs isn't a value of that appender in 1.2.  You may be
> thinking of RollingFileAppender or 1.3.

The question is, "what is log4j thinking of?". After all, it is log4j that says:

>> log4j:WARN No such property [maxLogs] in
>> org.apache.log4j.DailyRollingFileAppender.

>
> Don't put the pattern in the File value.
>   value="logs/LogFile.log"/>

Hmm. Removing the pattern certainly makes the pattern bit disappear from the 
filename. But all I am left with is literally what is in the value. So now my 
logfile is called LogFile.log! How can I get the date/time into the filename 
please? I expected it to appear in the format -MM-dd, i.e. modelled after 
the DatePattern.

BTW, I really appreciate this rapid feedback. Thanks very much!

-Andrew

>
> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
>> James Stauffer wrote:
>>> There are no included appenders that can do that.  You could easily
>>> write your own appender to do that or use DailyRollingFileAppender
>>> to roll every hour and then have 6 files for each "watch".
>>
>> ok, but ...
>>
>> The name of the file that gets created contains a literal
>> '-MM-dd-a' rather than the actual date/time I expected. What am
>> I doing wrong please? Finally, the program gives a warning at
>> startup:
>> log4j:WARN No such property [maxLogs] in
>> org.apache.log4j.DailingRollingFileAppender.
>> What does this mean please? How can I make this problem go away?
>>>
>>> On 3/16/07, Andrew Marlow <[EMAIL PROTECTED]> wrote:
 Hello guys,

 I am new to log4j so please bear with me. I am writing a program in
 java that used to be written in C++. The C++ program used a
 home-grown logger. I am trying to use log4j to do the logging. The
 homegrown logger used to write 4 logfiles per day; the files were
 considered as watches of a 6 hour duration (->0600, 0600->1200,
 1200->1800 and 1800->2400). It looks to me like I might be able to
 use DailyRollingFileAppender to do a similar job.



**"
The data and information (collectively called Information) herein is the sole 
property of ICAP.  The Information is confidential, may be legally privileged 
and is intended solely for the use of the individual or entity to whom it is 
addressed.  Unauthorised disclosure, copying or distribution of the Information 
is strictly prohibited and the recipient of the Information shall not 
redistribute the Information in any form to a third party.  If you received 
this Information in error please tell us by reply (or telephone the sender) and 
delete all copies on your system.

References in this Information to ICAP are references to ICAP plc, a company 
incorporated in England with registered number 3611426 whose registered office 
is 2 Broadgate, London, EC2M 7UR and where the context requires, includes its 
subsidiary and associated undertakings.  As applicable, certain companies 
within the ICAP group are authorised and regulated by the Financial Services 
Authority.  Any investment research sent from ICAP will provide an impartial 
and objective assessment of the securities, companies or other matters that are 
the subject of their research and our Conflicts of Interest Management Policy 
regarding investment research can be viewed by requesting a copy from your 
usual contact at ICAP.  Please visit www.icap.com for further regulatory 
information including details regarding the European eCommerce Directive.

***"
We have taken precautions to minimise the risk of transmitting software viruses, but 
we advise you to carry out your own virus checks on any attachment to this message. 
We cannot accept liability for any loss or damage caused by software viruses. "
***


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





--
James 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 

Re: Inconsistancy between logger.XXX("message") and logger.isXXXEnabled()

2007-03-16 Thread John Eisenman

Hi,

I'm sorry, it looks like I posted the wrong information; the .xml file 
that I described is the reverse of that which illustrates the situation.


The correct situation is that this xml file:



 
   
   
 
 
 


 
   
   
  



results in this output:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
2[main] INFO  chapter3.BugApp3  - Exiting application.

If I instead set the root level to "info", then I get this:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
1[main] INFO  chapter3.BugApp3  - Exiting application.

So, the observation is that log4j says that Debug is enabled even when 
there are no appenders that log that level. 
Seems that it would be more desirable  to return  False in that situation.


-John


I just did a test with 1.2.8 and got different results.  Please retest.




On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote:
> I'm using version 1.2.14
>
> My expectation in using log4j was that a call to logger.isXXXEnabled()
> would return true only in the case that a call to logger.XXX("some
> message") would result in the message being written to some appender.
> However, it appears that the existence of an appender has no 
bearing the

> Enabled call.
>
> For example, I have this simple configuration:
>
> 
> 
>
> 
>
>   
> 
> 
>   

> 
>   
>
>   
> 
> 
>   
> 
>
>
> Using this configuration, and this program (based on log4j's 
examples):

>
>
> package chapter3;
>
> import org.apache.log4j.Logger;
> import org.apache.log4j.xml.DOMConfigurator;
>
> public class BugApp3 {
> //final static Logger logger = Logger.getLogger(BugApp3.class);
> final static Logger logger = Logger.getLogger("chapter3.BugApp3");
>
>   public static void main(String[] args) {
> DOMConfigurator.configure(args[0]);
>
> logger.info("Entering application.");
>
> //debug is not enabled
> logger.debug("Debug is enabled.");
>
> if (logger.isDebugEnabled()) {
> logger.info("isDebugEnabled() returns true!");
> }
>
> logger.info("Exiting application.");
>   }
> }
>
> I see the following output:
>
> % java chapter3.BugApp3 bug0.xml
> 0[main] INFO  chapter3.BugApp3  - Entering application.
> 2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
> 3[main] INFO  chapter3.BugApp3  - Exiting application.
>
> However, if I set the root level to "debug" instead, then I get this
> output instead:
>
> % java chapter3.BugApp3 bug0.xml
> 1[main] INFO  chapter3.BugApp3  - Entering application.
> 3[main] INFO  chapter3.BugApp3  - Exiting application.
>
> Since the goal of an isXXXEnabled() statement is to avoid doing
> unnecessary work in the case where it will not result in actual debug
> output, it seems unfortunate that it does not take into account the
> existence of an appender.
>
> Is this behavior intentional?
>
> -John
>
>
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
James 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: Inconsistancy between logger.XXX("message") and logger.isXXXEnabled()

2007-03-16 Thread John Eisenman
The benefit would be that code that uses log4j would always run as 
optimally as possible even if a  Sys-Op was not aware of the need to 
change both the level and the threshold.

What would the benefit of that change be?  You could easily set the
logger level to the minimum of all attached appenders to get the same
effect.

On 3/16/07, John Eisenman <[EMAIL PROTECTED]> wrote:

Hi,

I'm sorry, it looks like I posted the wrong information; the .xml file
that I described is the reverse of that which illustrates the situation.

The correct situation is that this xml file:



  


  


  

  


  


results in this output:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
2[main] INFO  chapter3.BugApp3  - Exiting application.

If I instead set the root level to "info", then I get this:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
1[main] INFO  chapter3.BugApp3  - Exiting application.

So, the observation is that log4j says that Debug is enabled even when
there are no appenders that log that level.
Seems that it would be more desirable  to return  False in that 
situation.


-John

> I just did a test with 1.2.8 and got different results.  Please 
retest.

>
>>
>>
>> On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote:
>> > I'm using version 1.2.14
>> >
>> > My expectation in using log4j was that a call to 
logger.isXXXEnabled()

>> > would return true only in the case that a call to logger.XXX("some
>> > message") would result in the message being written to some 
appender.

>> > However, it appears that the existence of an appender has no
>> bearing the
>> > Enabled call.
>> >
>> > For example, I have this simple configuration:
>> >
>> > 
>> > 
>> >
>> > xmlns:log4j='http://jakarta.apache.org/log4j/'>

>> >
>> >   
>> > 
>> > 
>> >   
>> > 
>> >   
>> >
>> >   
>> > 
>> > 
>> >   
>> > 
>> >
>> >
>> > Using this configuration, and this program (based on log4j's
>> examples):
>> >
>> >
>> > package chapter3;
>> >
>> > import org.apache.log4j.Logger;
>> > import org.apache.log4j.xml.DOMConfigurator;
>> >
>> > public class BugApp3 {
>> > //final static Logger logger = Logger.getLogger(BugApp3.class);
>> > final static Logger logger = 
Logger.getLogger("chapter3.BugApp3");

>> >
>> >   public static void main(String[] args) {
>> > DOMConfigurator.configure(args[0]);
>> >
>> > logger.info("Entering application.");
>> >
>> > //debug is not enabled
>> > logger.debug("Debug is enabled.");
>> >
>> > if (logger.isDebugEnabled()) {
>> > logger.info("isDebugEnabled() returns true!");
>> > }
>> >
>> > logger.info("Exiting application.");
>> >   }
>> > }
>> >
>> > I see the following output:
>> >
>> > % java chapter3.BugApp3 bug0.xml
>> > 0[main] INFO  chapter3.BugApp3  - Entering application.
>> > 2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns 
true!

>> > 3[main] INFO  chapter3.BugApp3  - Exiting application.
>> >
>> > However, if I set the root level to "debug" instead, then I get 
this

>> > output instead:
>> >
>> > % java chapter3.BugApp3 bug0.xml
>> > 1[main] INFO  chapter3.BugApp3  - Entering application.
>> > 3[main] INFO  chapter3.BugApp3  - Exiting application.
>> >
>> > Since the goal of an isXXXEnabled() statement is to avoid doing
>> > unnecessary work in the case where it will not result in actual 
debug

>> > output, it seems unfortunate that it does not take into account the
>> > existence of an appender.
>> >
>> > Is this behavior intentional?
>> >
>> > -John
>> >
>> >
>> >
>> >
>> >
>> > 
-

>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>>
>> --
>> James 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]








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



Re: Inconsistancy between logger.XXX("message") and logger.isXXXEnabled()

2007-03-16 Thread James Stauffer

What would the benefit of that change be?  You could easily set the
logger level to the minimum of all attached appenders to get the same
effect.

On 3/16/07, John Eisenman <[EMAIL PROTECTED]> wrote:

Hi,

I'm sorry, it looks like I posted the wrong information; the .xml file
that I described is the reverse of that which illustrates the situation.

The correct situation is that this xml file:



  


  

  

  


  


results in this output:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
2[main] INFO  chapter3.BugApp3  - Exiting application.

If I instead set the root level to "info", then I get this:

% java chapter3.BugApp3 bug0.xml
0[main] INFO  chapter3.BugApp3  - Entering application.
1[main] INFO  chapter3.BugApp3  - Exiting application.

So, the observation is that log4j says that Debug is enabled even when
there are no appenders that log that level.
Seems that it would be more desirable  to return  False in that situation.

-John

> I just did a test with 1.2.8 and got different results.  Please retest.
>
>>
>>
>> On 3/15/07, John Eisenman <[EMAIL PROTECTED]> wrote:
>> > I'm using version 1.2.14
>> >
>> > My expectation in using log4j was that a call to logger.isXXXEnabled()
>> > would return true only in the case that a call to logger.XXX("some
>> > message") would result in the message being written to some appender.
>> > However, it appears that the existence of an appender has no
>> bearing the
>> > Enabled call.
>> >
>> > For example, I have this simple configuration:
>> >
>> > 
>> > 
>> >
>> > 
>> >
>> >   
>> > 
>> > 
>> >   
>> > 
>> >   
>> >
>> >   
>> > 
>> > 
>> >   
>> > 
>> >
>> >
>> > Using this configuration, and this program (based on log4j's
>> examples):
>> >
>> >
>> > package chapter3;
>> >
>> > import org.apache.log4j.Logger;
>> > import org.apache.log4j.xml.DOMConfigurator;
>> >
>> > public class BugApp3 {
>> > //final static Logger logger = Logger.getLogger(BugApp3.class);
>> > final static Logger logger = Logger.getLogger("chapter3.BugApp3");
>> >
>> >   public static void main(String[] args) {
>> > DOMConfigurator.configure(args[0]);
>> >
>> > logger.info("Entering application.");
>> >
>> > //debug is not enabled
>> > logger.debug("Debug is enabled.");
>> >
>> > if (logger.isDebugEnabled()) {
>> > logger.info("isDebugEnabled() returns true!");
>> > }
>> >
>> > logger.info("Exiting application.");
>> >   }
>> > }
>> >
>> > I see the following output:
>> >
>> > % java chapter3.BugApp3 bug0.xml
>> > 0[main] INFO  chapter3.BugApp3  - Entering application.
>> > 2[main] INFO  chapter3.BugApp3  - isDebugEnabled() returns true!
>> > 3[main] INFO  chapter3.BugApp3  - Exiting application.
>> >
>> > However, if I set the root level to "debug" instead, then I get this
>> > output instead:
>> >
>> > % java chapter3.BugApp3 bug0.xml
>> > 1[main] INFO  chapter3.BugApp3  - Entering application.
>> > 3[main] INFO  chapter3.BugApp3  - Exiting application.
>> >
>> > Since the goal of an isXXXEnabled() statement is to avoid doing
>> > unnecessary work in the case where it will not result in actual debug
>> > output, it seems unfortunate that it does not take into account the
>> > existence of an appender.
>> >
>> > Is this behavior intentional?
>> >
>> > -John
>> >
>> >
>> >
>> >
>> >
>> > -
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>>
>> --
>> James 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]





--
James 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: large amounts of 0 characters at beginning of log

2007-03-16 Thread Ceki Gülcü

Hi Jeff,

Couple of questions. Are multiple processes writing to the same file? Are 
you using the configureAndWatch method?


At 01:39 PM 3/16/2007, Jeff Drew wrote:

I'm having a problem in one installation where approximately 8 Mb of 0x00
appear at the start of the log file.  Then the file contains typical log
output.  A typical RollingFileAppender writes to this file.
MaxFileSize=10KB and MaxBackupIndex=3.

Since this log is what I use for application diagnosis, I'm struggling to
identify what initiates this problem.

Does this sound similar to known mis-configurations, problems, etc?  Any
suggestions on how to diagnose this problem?

Thanks


--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


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



Re: large amounts of 0 characters at beginning of log

2007-03-16 Thread Jeff Drew

Hi Ceki,

Thanks for responding.

1.  My application is multithreaded and has multiple logging subjects, but
only one RollingFileAppender for this log file. So approximately 30 threads
call logSubject1.info(), logSubject2.info(), etc.  But these all use the
same appender.

2.   I am using configureAndWatch set to 1.

Thanks

Jeff

On 3/16/07, Ceki Gülcü <[EMAIL PROTECTED]> wrote:


Hi Jeff,

Couple of questions. Are multiple processes writing to the same file? Are
you using the configureAndWatch method?

At 01:39 PM 3/16/2007, Jeff Drew wrote:
>I'm having a problem in one installation where approximately 8 Mb of 0x00
>appear at the start of the log file.  Then the file contains typical log
>output.  A typical RollingFileAppender writes to this file.
>MaxFileSize=10KB and MaxBackupIndex=3.
>
>Since this log is what I use for application diagnosis, I'm struggling to
>identify what initiates this problem.
>
>Does this sound similar to known mis-configurations, problems, etc?  Any
>suggestions on how to diagnose this problem?
>
>Thanks

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for
Java.
http://logback.qos.ch


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