Re: Clarification on
Thanks so much for responding to me Ralph! (and promptly) I think this is really useful information that you shared that would be a relief to many users. Users that only use Log4j2 via Slf4j are mitigated by this technique. That's a big deal! Most other users using Log4j2 directly would as well, I think. The wording of a "discredited" mitigation is not a word I would have used. I audited Message implementations that don't implement StringBuilderFormattable, thus those that could get around this system property mitigation: * RenderedMessage & LocalizedMessage: used in "log4j-1.2-api" -- a legacy bridge from Log4j 1.2. * StatusMessage: This is for debugging Log4j2 internally? Thus as long as log4j itself wouldn't log user input (not plausible to me), we should be safe. * MessageFormatMessage: Used "log4j-jul" module -- thus users using Log4j 2.x API but want to log to JUL. Anyway, it doesn't matter since the vulnerability risk is in log4j-core which wouldn't be used in this scenario. * ObjectArrayMessage: Only used in tests. Appears to be leftover tech-debt from some previous time when there was a CSV layout. * FlowMessage: Appears used for trace logging method entry/exit. I suppose someone configuring logging could enable this, and if it were done on a method with user input, then there is a risk. Right? * FormattedMessage: Not used except for indirectly via LocalizedMessage referenced above. * StringFormattedMessage: * Used in Logger.printf(). (not used by Slf4j) * Used in LogManager.getFormattedLogger. (not used by Slf4j) And one or two more are only used in log4j-perf. ~ David Smiley Apache Lucene/Solr Search Developer http://www.linkedin.com/in/davidwsmiley On Tue, Dec 21, 2021 at 9:40 AM Ralph Goers wrote: > The system property blocked lookups from being processed in what I would > call “normal” logging - those using the style logger.info(“Hello {}”, > name). However, > if you made a call like logger.printf(“Hello %s”, name) lookups would not > be blocked. > > If you obtained your logger with a special LoggerFactory such as > > Logger logger = LogManager.getLogger(name, new > MessageFormatMessageFactory()); > > Then in all likelihood the resulting logging calls would not have lookups > blocked. > So if you know that you only log using ParameterizedMessage (the kind with > {}) > then using the system property would work. > > The problem is that the property is only blocking Messages that implement > StringBuilderFormattable. ParameterizedLayout does while the printf method > uses StringFormattedMessage which does not implement that interface. > > Ralph > > > On Dec 21, 2021, at 6:23 AM, David Smiley wrote: > > > > Hello, > > > > I'm on the Apache Solr PMC, and I'm trying to do some due diligence on > > understanding the extent to which "log4j2.formatMsgNoLookups" may or may > > not be effective in mitigating certain vulnerabilities *for Solr*. Solr > > recently upgraded to Log4j 2.16 but I want to validate the extent to > which > > this mitigation measure is appropriate for older versions of Solr. > Log4j's > > news page[1] has the following text: > > > > *Older (discredited) mitigation measures* > >> > >> This page previously mentioned other mitigation measures, but we > >> discovered that these measures only limit exposure while leaving some > >> attack vectors open. > >> > > Other insufficient mitigation measures are: setting system property > >> log4j2.formatMsgNoLookups or environment variable > >> LOG4J_FORMAT_MSG_NO_LOOKUPS to true for releases >= 2.10, or modifying > the > >> logging configuration to disable message lookups with %m{nolookups}, > >> %msg{nolookups} or %message{nolookups} for releases >= 2.7 and <= > 2.14.1. > >> > >> The reason these measures are insufficient is that, in addition to the > >> Thread Context attack vector mentioned above, there are still code > paths in > >> Log4j where message lookups could occur: known examples are applications > >> that use Logger.printf("%s", userInput), or applications that use a > custom > >> message factory, where the resulting messages do not implement > >> StringBuilderFormattable. There may be other attack vectors. > >> > > [1]: https://logging.apache.org/log4j/2.x/security.html#CVE-2021-45105 > > > > The use of the word "discredited" is suggestive that this > > log4j2.formatMsgNoLookups setting will be of no use to anyone. My > > suspicion is that it can be, but is dependent on the extent to which the > > application (Solr + Slf4j) actually uses Log4j2. It is worth spending > time > > understanding this (instead of throwing up your hands and saying, just > > upgrade) because upgrading is quite a hassle for many users. Many users > of > > Log4j only use Log4j via Slf4j which is comparatively easier to audit. > > Solr is not quite in this camp; it injects a custom appender in order to > > render messages on it's logging UI. > > > > Taking a specific example here given in the news page: Logger.printf. > I'm >
Re: Clarification on
The system property blocked lookups from being processed in what I would call “normal” logging - those using the style logger.info(“Hello {}”, name). However, if you made a call like logger.printf(“Hello %s”, name) lookups would not be blocked. If you obtained your logger with a special LoggerFactory such as Logger logger = LogManager.getLogger(name, new MessageFormatMessageFactory()); Then in all likelihood the resulting logging calls would not have lookups blocked. So if you know that you only log using ParameterizedMessage (the kind with {}) then using the system property would work. The problem is that the property is only blocking Messages that implement StringBuilderFormattable. ParameterizedLayout does while the printf method uses StringFormattedMessage which does not implement that interface. Ralph > On Dec 21, 2021, at 6:23 AM, David Smiley wrote: > > Hello, > > I'm on the Apache Solr PMC, and I'm trying to do some due diligence on > understanding the extent to which "log4j2.formatMsgNoLookups" may or may > not be effective in mitigating certain vulnerabilities *for Solr*. Solr > recently upgraded to Log4j 2.16 but I want to validate the extent to which > this mitigation measure is appropriate for older versions of Solr. Log4j's > news page[1] has the following text: > > *Older (discredited) mitigation measures* >> >> This page previously mentioned other mitigation measures, but we >> discovered that these measures only limit exposure while leaving some >> attack vectors open. >> > Other insufficient mitigation measures are: setting system property >> log4j2.formatMsgNoLookups or environment variable >> LOG4J_FORMAT_MSG_NO_LOOKUPS to true for releases >= 2.10, or modifying the >> logging configuration to disable message lookups with %m{nolookups}, >> %msg{nolookups} or %message{nolookups} for releases >= 2.7 and <= 2.14.1. >> >> The reason these measures are insufficient is that, in addition to the >> Thread Context attack vector mentioned above, there are still code paths in >> Log4j where message lookups could occur: known examples are applications >> that use Logger.printf("%s", userInput), or applications that use a custom >> message factory, where the resulting messages do not implement >> StringBuilderFormattable. There may be other attack vectors. >> > [1]: https://logging.apache.org/log4j/2.x/security.html#CVE-2021-45105 > > The use of the word "discredited" is suggestive that this > log4j2.formatMsgNoLookups setting will be of no use to anyone. My > suspicion is that it can be, but is dependent on the extent to which the > application (Solr + Slf4j) actually uses Log4j2. It is worth spending time > understanding this (instead of throwing up your hands and saying, just > upgrade) because upgrading is quite a hassle for many users. Many users of > Log4j only use Log4j via Slf4j which is comparatively easier to audit. > Solr is not quite in this camp; it injects a custom appender in order to > render messages on it's logging UI. > > Taking a specific example here given in the news page: Logger.printf. I'm > not seeing the problem; can someone offer me a pointer? I've checked out a > version of Solr that uses Log4j 2.14.1 and set the system property, and > crafted up some trivial unit test that calls Logger.printf with the intent > of exploring what happens internally that is concerning. I do see the > problem in MessagePatternConverter that is averted by the system property. > > Feel free to reach me directly if there are sensitivities to a response. > > ~ David Smiley > Apache Lucene/Solr Search Developer > http://www.linkedin.com/in/davidwsmiley - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
RE: Clarification & More help required
You are confusing OS environment variables with Java System environment variables. If you want to be able to read ${JAVA_HOME} in a Log4j config file, you will have to set it as a Java System variable. You can do this programmatically or, maybe even more simply, on the command line java -DJAVA_HOME=%JAVA_HOME% MyProgram Jake At 11:19 AM 7/7/2005 +0530, you wrote: >Hi All, >I am also facing similar problem ! Log4j is unable read the env >variables. My problem is I cant hard code the path of the log file as >C:\XXX\xxLog.log. I have to read the relative path for this purpose . >Any idea ? > >I am using OC4J & log4J 1.2.11 & My log4j.xml is as below. > > > >http://jakarta.apache.org/log4j/"; >debug="false"> > class="org.apache.log4j.DailyRollingFileAppender"> > value="$(JAVA_HOME)/DAOFramework.log"/> > > > > > > class="org.apache.log4j.ConsoleAppender"> > > > > > value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> > > > > > > > > > > > > > > > > > > > > And I am getting errors like : > >Oracle Application Server Containers for J2EE 10g (9.0.4.0.0) >initialized >log4j:ERROR setFile(null,true) call failed. >java.io.FileNotFoundException: $(JAVA_HOME)/DAOFramework.log (The system >cannot find the path specified) > at java.io.FileOutputStream.openAppend(Native Method) > at java.io.FileOutputStream.(Unknown Source) > at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) > at >org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) > at >org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFi >leAppender.java:215) > at >org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) > at >org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java: >219) > at >org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator. >java:149) > > > >I am calling Logger like this in Java Code : > Logger logger =Logger.getLogger("DAO"); > logger.info("I am inside logger"+this); > >Regards, >Sriram V > > >-Original Message- >From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] >Sent: Wednesday, July 06, 2005 9:59 PM >To: 'Log4J Users List' >Subject: RE: Clarification > >Did u try ${some_property_key} (for example, java.home or user.home >system >properties) to specify the path in front of the File. > >Ex: > >log4j.appender.dest2.File=${java.home}/log4j.log > >~vinodh > >-Original Message- >From: Balaji Saranathan [mailto:[EMAIL PROTECTED] >Sent: Wednesday, July 06, 2005 11:06 AM >To: 'Log4J Users List' >Subject: RE: Clarification > > >But isnt this configuring through the code? I want to configure the >FileAppender from the log4j.properties file. > > >-Original Message- >From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] >Sent: Wednesday, July 06, 2005 12:01 PM >To: 'Log4J Users List' >Subject: RE: Clarification > > >See the attached code, > > > >// Set FileAppender > >SimpleLayout layout = new SimpleLayout(); > >String fileName = new >File(backupDir.getParent(),"error.log").getAbsolutePath(); > >FileAppender appender = new FileAppender(layout, >fileName,true); > > > >logger.addAppender(appender); > > logger.setLevel((Level) Level.FATAL); > >Date date = new Date(System.currentTimeMillis()); > > > >logger.fatal(date.toString()); > >logger.fatal(message); > > >logger.fatal("***"); > > > >Note: > >Make sure you give the parent dir to the log file properly. > > > >~vinodh > >-Original Message- >From: Balaji Saranathan [mailto:[EMAIL PROTECTED] >Sent: Wednesday, July 06, 2005 10:47 AM >To: 'Log4J Users List' >Subject: RE: Clarification > > > > > >Tx. I tried it. It doesn't work I still get the same error. In the error > >below, there is a call to setFile with "null" filename. Shdnt it be > >called with the filen
Re: Clarification & More help required
AFAIK you can only use Java System properties. To set them pass them on the Java command with "-D" On 7/7/05, Sriram Venkatasubramanian <[EMAIL PROTECTED]> wrote: > Hi All, > I am also facing similar problem ! Log4j is unable read the env > variables. My problem is I cant hard code the path of the log file as > C:\XXX\xxLog.log. I have to read the relative path for this purpose . > Any idea ? > > I am using OC4J & log4J 1.2.11 & My log4j.xml is as below. > > > > http://jakarta.apache.org/log4j/"; > debug="false"> > class="org.apache.log4j.DailyRollingFileAppender"> > value="$(JAVA_HOME)/DAOFramework.log"/> > > > > > > class="org.apache.log4j.ConsoleAppender"> > > > > > value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> > > > > > > > > > > > > > > > > > > > > And I am getting errors like : > > Oracle Application Server Containers for J2EE 10g (9.0.4.0.0) > initialized > log4j:ERROR setFile(null,true) call failed. > java.io.FileNotFoundException: $(JAVA_HOME)/DAOFramework.log (The system > cannot find the path specified) > at java.io.FileOutputStream.openAppend(Native Method) > at java.io.FileOutputStream.(Unknown Source) > at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) > at > org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) > at > org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFi > leAppender.java:215) > at > org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) > at > org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java: > 219) > at > org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator. > java:149) > > > > I am calling Logger like this in Java Code : > Logger logger =Logger.getLogger("DAO"); > logger.info("I am inside logger"+this); > > Regards, > Sriram V > > > -Original Message- > From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 9:59 PM > To: 'Log4J Users List' > Subject: RE: Clarification > > Did u try ${some_property_key} (for example, java.home or user.home > system > properties) to specify the path in front of the File. > > Ex: > > log4j.appender.dest2.File=${java.home}/log4j.log > > ~vinodh > > -Original Message- > From: Balaji Saranathan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 11:06 AM > To: 'Log4J Users List' > Subject: RE: Clarification > > > But isnt this configuring through the code? I want to configure the > FileAppender from the log4j.properties file. > > > -Original Message- > From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 12:01 PM > To: 'Log4J Users List' > Subject: RE: Clarification > > > See the attached code, > > > > // Set FileAppender > > SimpleLayout layout = new SimpleLayout(); > > String fileName = new > File(backupDir.getParent(),"error.log").getAbsolutePath(); > > FileAppender appender = new FileAppender(layout, > fileName,true); > > > > logger.addAppender(appender); > > logger.setLevel((Level) Level.FATAL); > > Date date = new Date(System.currentTimeMillis()); > > > > logger.fatal(date.toString()); > > logger.fatal(message); > > > logger.fatal("***"); > > > > Note: > > Make sure you give the parent dir to the log file properly. > > > > ~vinodh > > -Original Message- > From: Balaji Saranathan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 10:47 AM > To: 'Log4J Users List' > Subject: RE: Clarification > > > > > > Tx. I tried it. It doesn't work I still get the same error. In the error > > below, there is a call to setFile with "null" filename. Shdnt it be > > call
RE: Clarification & More help required
Hi All, I am also facing similar problem ! Log4j is unable read the env variables. My problem is I cant hard code the path of the log file as C:\XXX\xxLog.log. I have to read the relative path for this purpose . Any idea ? I am using OC4J & log4J 1.2.11 & My log4j.xml is as below. http://jakarta.apache.org/log4j/"; debug="false"> And I am getting errors like : Oracle Application Server Containers for J2EE 10g (9.0.4.0.0) initialized log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: $(JAVA_HOME)/DAOFramework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(Unknown Source) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFi leAppender.java:215) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java: 219) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator. java:149) I am calling Logger like this in Java Code : Logger logger =Logger.getLogger("DAO"); logger.info("I am inside logger"+this); Regards, Sriram V -Original Message- From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 9:59 PM To: 'Log4J Users List' Subject: RE: Clarification Did u try ${some_property_key} (for example, java.home or user.home system properties) to specify the path in front of the File. Ex: log4j.appender.dest2.File=${java.home}/log4j.log ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:06 AM To: 'Log4J Users List' Subject: RE: Clarification But isnt this configuring through the code? I want to configure the FileAppender from the log4j.properties file. -Original Message- From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 12:01 PM To: 'Log4J Users List' Subject: RE: Clarification See the attached code, // Set FileAppender SimpleLayout layout = new SimpleLayout(); String fileName = new File(backupDir.getParent(),"error.log").getAbsolutePath(); FileAppender appender = new FileAppender(layout, fileName,true); logger.addAppender(appender); logger.setLevel((Level) Level.FATAL); Date date = new Date(System.currentTimeMillis()); logger.fatal(date.toString()); logger.fatal(message); logger.fatal("***"); Note: Make sure you give the parent dir to the log file properly. ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:47 AM To: 'Log4J Users List' Subject: RE: Clarification Tx. I tried it. It doesn't work I still get the same error. In the error below, there is a call to setFile with "null" filename. Shdnt it be called with the filename mentioned in the properties file? -Original Message- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:38 AM To: 'Log4J Users List' Subject: RE: Clarification If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Nati
RE: Clarification
Thanks ...that saves my effort on investigating further. -Original Message- From: Mark Womack [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 1:35 PM To: 'Log4J Users List' Subject: RE: Clarification This is bug 9150 in the log4j bug db, and will be fixed in the upcoming 1.2.12 version. I got the fix together over the weekend, but still working on a unit test before checking it into cvs. -Mark > -Original Message- > From: James Stauffer [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 10:07 AM > To: Log4J Users List; [EMAIL PROTECTED] > Subject: Re: Clarification > > log4j will create the file but not the directories. (I ended up > creating my own appender that creates the directories also). > > On 7/6/05, Balaji Saranathan <[EMAIL PROTECTED]> wrote: > > Can you tell me if log4j creates the log file (if they are not > > present) when using the FileAppenders or is it the responsibility of > > the developers to create the log files? > > -- > James Stauffer > 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] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Clarification
This is bug 9150 in the log4j bug db, and will be fixed in the upcoming 1.2.12 version. I got the fix together over the weekend, but still working on a unit test before checking it into cvs. -Mark > -Original Message- > From: James Stauffer [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 10:07 AM > To: Log4J Users List; [EMAIL PROTECTED] > Subject: Re: Clarification > > log4j will create the file but not the directories. (I ended up > creating my own appender that creates the directories also). > > On 7/6/05, Balaji Saranathan <[EMAIL PROTECTED]> wrote: > > Can you tell me if log4j creates the log file (if they are not present) > > when using the FileAppenders or is it the responsibility of the > > developers to create the log files? > > -- > James Stauffer > 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: Clarification
log4j will create the file but not the directories. (I ended up creating my own appender that creates the directories also). On 7/6/05, Balaji Saranathan <[EMAIL PROTECTED]> wrote: > Can you tell me if log4j creates the log file (if they are not present) > when using the FileAppenders or is it the responsibility of the > developers to create the log files? -- James Stauffer 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: Clarification
Did u try ${some_property_key} (for example, java.home or user.home system properties) to specify the path in front of the File. Ex: log4j.appender.dest2.File=${java.home}/log4j.log ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:06 AM To: 'Log4J Users List' Subject: RE: Clarification But isnt this configuring through the code? I want to configure the FileAppender from the log4j.properties file. -Original Message- From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 12:01 PM To: 'Log4J Users List' Subject: RE: Clarification See the attached code, // Set FileAppender SimpleLayout layout = new SimpleLayout(); String fileName = new File(backupDir.getParent(),"error.log").getAbsolutePath(); FileAppender appender = new FileAppender(layout, fileName,true); logger.addAppender(appender); logger.setLevel((Level) Level.FATAL); Date date = new Date(System.currentTimeMillis()); logger.fatal(date.toString()); logger.fatal(message); logger.fatal("***"); Note: Make sure you give the parent dir to the log file properly. ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:47 AM To: 'Log4J Users List' Subject: RE: Clarification Tx. I tried it. It doesn't work I still get the same error. In the error below, there is a call to setFile with "null" filename. Shdnt it be called with the filename mentioned in the properties file? -Original Message- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:38 AM To: 'Log4J Users List' Subject: RE: Clarification If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:177) at java.io.FileOutputStream.(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16 5) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :132) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :96) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator .java:654) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator .java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf igurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver ter.java:468) Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
RE: Clarification
Usually I configure by XML file and I am not quite shure, but: > log4j.appender.framework.File=framework.log=./logs/framework.log seems to have one "=" to much. Did it work with your first version "log4j.appender.framework.File=framework.log" ? Heri > -Original Message- > From: Balaji Saranathan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 06, 2005 5:33 PM > To: 'Log4J Users List' > Subject: Clarification > > > > > Hi, > > Can you tell me if log4j creates the log file (if they are > not present) > when using the FileAppenders or is it the responsibility of the > developers to create the log files? > I have a FileAppender configured and when I configure the > log4j.appender.framework.File=framework.log=./logs/framework.log > I get a the following error on stdout.log > > log4j:ERROR setFile(null,true) call failed. > java.io.FileNotFoundException: .\logs\framework.log (The system cannot > find the path specified) > at java.io.FileOutputStream.openAppend(Native Method) > at java.io.FileOutputStream.(FileOutputStream.java:177) > at java.io.FileOutputStream.(FileOutputStream.java:102) > at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) > at > org.apache.log4j.RollingFileAppender.setFile(RollingFileAppend > er.java:16 > 5) > at > org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) > at > org.apache.log4j.config.PropertySetter.activate(PropertySetter > .java:256) > at > org.apache.log4j.config.PropertySetter.setProperties(PropertyS > etter.java > :132) > at > org.apache.log4j.config.PropertySetter.setProperties(PropertyS > etter.java > :96) > at > org.apache.log4j.PropertyConfigurator.parseAppender(PropertyCo > nfigurator > .java:654) > at > org.apache.log4j.PropertyConfigurator.parseCategory(PropertyCo > nfigurator > .java:612) > at > org.apache.log4j.PropertyConfigurator.configureRootCategory(Pr > opertyConf > igurator.java:509) > at > org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConf > igurator.j > ava:415) > at > org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConf > igurator.j > ava:441) > at > org.apache.log4j.helpers.OptionConverter.selectAndConfigure(Op > tionConver > ter.java:468) > > > > > > > > Confidentiality Notice > > The information contained in this electronic message and any > attachments to this message are intended > for the exclusive use of the addressee(s) and may contain > confidential or privileged information. If > you are not the intended recipient, please notify the sender > at Wipro or [EMAIL PROTECTED] immediately > and destroy all copies of this message and any attachments. > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Clarification
But isnt this configuring through the code? I want to configure the FileAppender from the log4j.properties file. -Original Message- From: Vinodh Srinivasasainagendra [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 12:01 PM To: 'Log4J Users List' Subject: RE: Clarification See the attached code, // Set FileAppender SimpleLayout layout = new SimpleLayout(); String fileName = new File(backupDir.getParent(),"error.log").getAbsolutePath(); FileAppender appender = new FileAppender(layout, fileName,true); logger.addAppender(appender); logger.setLevel((Level) Level.FATAL); Date date = new Date(System.currentTimeMillis()); logger.fatal(date.toString()); logger.fatal(message); logger.fatal("***"); Note: Make sure you give the parent dir to the log file properly. ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:47 AM To: 'Log4J Users List' Subject: RE: Clarification Tx. I tried it. It doesn't work I still get the same error. In the error below, there is a call to setFile with "null" filename. Shdnt it be called with the filename mentioned in the properties file? -Original Message- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:38 AM To: 'Log4J Users List' Subject: RE: Clarification If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:177) at java.io.FileOutputStream.(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16 5) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :132) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :96) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator .java:654) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator .java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf igurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver ter.java:468) Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The informati
RE: Clarification
See the attached code, // Set FileAppender SimpleLayout layout = new SimpleLayout(); String fileName = new File(backupDir.getParent(),"error.log").getAbsolutePath(); FileAppender appender = new FileAppender(layout, fileName,true); logger.addAppender(appender); logger.setLevel((Level) Level.FATAL); Date date = new Date(System.currentTimeMillis()); logger.fatal(date.toString()); logger.fatal(message); logger.fatal("***"); Note: Make sure you give the parent dir to the log file properly. ~vinodh -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:47 AM To: 'Log4J Users List' Subject: RE: Clarification Tx. I tried it. It doesn't work I still get the same error. In the error below, there is a call to setFile with "null" filename. Shdnt it be called with the filename mentioned in the properties file? -Original Message- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:38 AM To: 'Log4J Users List' Subject: RE: Clarification If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:177) at java.io.FileOutputStream.(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16 5) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :132) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :96) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator .java:654) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator .java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf igurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver ter.java:468) Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Clarification
Tx. I tried it. It doesn't work I still get the same error. In the error below, there is a call to setFile with "null" filename. Shdnt it be called with the filename mentioned in the properties file? -Original Message- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 11:38 AM To: 'Log4J Users List' Subject: RE: Clarification If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:177) at java.io.FileOutputStream.(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16 5) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :132) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :96) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator .java:654) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator .java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf igurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver ter.java:468) Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Clarification
If can't find the path, have you tried removed the leading ./? For a path I would do logs/framework.log assuming that it is contained in the same directory that your class is running from. -Original Message- From: Balaji Saranathan [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 10:33 AM To: 'Log4J Users List' Subject: Clarification Hi, Can you tell me if log4j creates the log file (if they are not present) when using the FileAppenders or is it the responsibility of the developers to create the log files? I have a FileAppender configured and when I configure the log4j.appender.framework.File=framework.log=./logs/framework.log I get a the following error on stdout.log log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: .\logs\framework.log (The system cannot find the path specified) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:177) at java.io.FileOutputStream.(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:282) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16 5) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :132) at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java :96) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator .java:654) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator .java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf igurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j ava:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver ter.java:468) Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]