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 Mi...@retail-logic.com on 2003/07/10 14:20:09 UTC

configuring log4j without a file? is it possible?

Hello people,

In the examples people use they all seem to give the path of a config file
to configure log4j.
Is there anyway we can configure log4j (before it logs to a appender)
without giving it the path of a config file???
maybe get config from Database? another machine etc?
any ideas? solutions? i would be extremely grateful

Cheers.

_______________________________________________________________________________
 The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Statements and opinions expressed in this e-mail may not
represent those of the company. Any review, retransmission, dissemination
or other use of, or taking of any action in reliance upon, this information
by persons or entities other than the intended recipient is prohibited. If
you received this in error, please contact the sender immediately and
delete the material from any computer. This e-mail may be read by an
employee of the company as part of the internal monitoring process and is
therefore not to be considered private by the sender or the recipient.



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


Re: configuring log4j without a file? is it possible?

Posted by Vinodh Lakshminarayan <vi...@yahoo.com>.
Hi Michael,
     Yes it is possible. In fact we are reading our properties from a file and configuring the properties at run time. Below is an example. For the sake of simplicity I have placed some hard coded values and have used RollingFileAppender. A console appender can also be configured in the same way
 
  Logger  logInstance = Logger.getLogger("LogWriter");
  PatternLayout layout = new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %p  %m %n");
  String fullFileName = "D:/logs/WebLog.log";
  int fileSize = 10485760;
  int fileCount = 10;
  RollingFileAppender fileAppender = new RollingFileAppender(layout,fullFileName,true);
  fileAppender.setMaxBackupIndex(fileCount);
  fileAppender.setMaximumFileSize(fileSize);
  logInstance.addAppender(fileAppender);
 
  Hope this helps

Michael.Teji@retail-logic.com wrote:
Hello people,

In the examples people use they all seem to give the path of a config file
to configure log4j.
Is there anyway we can configure log4j (before it logs to a appender)
without giving it the path of a config file???
maybe get config from Database? another machine etc?
any ideas? solutions? i would be extremely grateful

Cheers.

_______________________________________________________________________________
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Statements and opinions expressed in this e-mail may not
represent those of the company. Any review, retransmission, dissemination
or other use of, or taking of any action in reliance upon, this information
by persons or entities other than the intended recipient is prohibited. If
you received this in error, please contact the sender immediately and
delete the material from any computer. This e-mail may be read by an
employee of the company as part of the internal monitoring process and is
therefore not to be considered private by the sender or the recipient.



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



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!