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 Johnny Gonzalez <jo...@yahoo.es> on 2005/01/03 19:46:44 UTC

RE: Loading configuration file

Hello,

I still have no success with log4j. I downloaded
1.2.9, and renamed my configuration file to
log4j.properties but it's not creating any log in the
log files. What can be wrong?

- I'm using eclipse 3.0.
- I tryed with the log files in the same directory of
my configuration file but doesn't work.
- my log4j.properties is into the root of the project
- my log4j configuration file looks like this:

#coloca los niveles de los loggers en debug y error, 
y adiciona appenders
log4j.logger.co.com=ERROR,ap1,ap2
log4j.logger.erroresStack=ERROR,ap3

#configuracion del appender 1
log4j.appender.ap1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ap1.DatePattern='.'yyyy-MM-dd
log4j.appender.ap1.File=logSEMC.txt
log4j.appender.ap1.threshold=DEBUG

#configuracion del appender 3
log4j.appender.ap3=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ap3.DatePattern='.'yyyy-MM-dd
log4j.appender.ap3.File=logSEMCErrores.txt
log4j.appender.ap3.threshold=ERROR

#configuracion del apender 2
log4j.appender.ap2=org.apache.log4j.ConsoleAppender

#layouts para los appenders
log4j.appender.ap1.layout=org.apache.log4j.PatternLayout
log4j.appender.ap1.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n

log4j.appender.ap2.layout=org.apache.log4j.PatternLayout
log4j.appender.ap2.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n

log4j.appender.ap3.layout=org.apache.log4j.PatternLayout
log4j.appender.ap3.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n

Any ideas?

Thanks,
Johnny


 --- Johnny Gonzalez <jo...@yahoo.es>
escribió: 
> Thanks a lot Kaufman,
> 
> I'm new in Java and I hear about Log4Java, so I
> wanted
> to use it to manage all logs in my applications, I
> didn't know how Java loaded the configuration file,
> know my questions are solved.
> 
> I will try both option to see what's best. Use the
> default configuration files and load another one
> from
> command line ;-)
> 
> Thanks a lot,
> Johnny
> 
>  --- Kaufman Ng <ka...@creditex.com> escribió: 
> > If you don't want to use the default
> > "log4j.properties" or "log4j.xml".
> > Just define the log4j.configuration system
> property
> > in command line similar
> > to this:
> > 
> > java -Dlog4j.configuration=log4j.props myClass
> > 
> > Hope this helps.
> > 
> > Kaufman Ng
> > 
> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: Thursday, December 30, 2004 7:33 PM
> > To: Log4J Users List
> > Subject: Re: Loading configuration file
> > 
> > 
> > 
> > Log4j looks for "log4j.properties" and "log4j.xml"
> > in the default 
> > package.  "log4j.props" or any name other than the
> > two I mentioned will not 
> > be picked up for auto configuration.  Also, you
> > might want to upgrade to 
> > 1.2.9.  I can't remember the version that started
> > picking up "log4j.xml", 
> > but I know for sure that both 1.2.8 and 1.2.9 do.
> > 
> > Jake
> > 



		
______________________________________________ 
Renovamos el Correo Yahoo!: ¡250 MB GRATIS! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

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


Re: Loading configuration file

Posted by Johnny Gonzalez <jo...@yahoo.es>.
Hello Jacob,

Thanks a lot for your help it was very useful. I have
several jar files that I need to invoke some services
from my server (jboss), and I note that one of those
jar files has a configuration file for log4j in the
server and as you said the file is log4j.xml, so when
I tryed to lot messages in my application it was using
the configuration file in the server.

Now I'm using this technique:

PropertyConfigurator logProperties = new
PropertyConfigurator();
		  logProperties.configure("conf/log4j.properties");

And now I am completely sure log4j is using this
configuration file.

Thanks a lot again,
Johnny

PS: I will follow your recommendation using the file
log4j.xml.

 --- Jacob Kjome <ho...@visi.com> escribió: 
> 
> And don't forget that if log4j.xml is in some
> directory on the classpath as 
> well, it will get used in preference to
> log4j.properties.  I suggest moving 
> to log4j.xml if at all possible.
> 
> Jake
> 
> At 04:57 PM 1/3/2005 -0600, you wrote:
>  >
>  >On Jan 3, 2005, at 3:47 PM, Johnny Gonzalez wrote:
>  >
>  >>
>  >> Hello Arnold,
>  >>
>  >> I Followed your recommendations, but it still
> doesn't
>  >> work. But for example when I make a:
>  >>
>  >> log.error("Variables");
>  >>
>  >> I'm receiving messages in the console like this:
>  >>
>  >> ERROR [main] (SemcControlador.java:280) -
> Variables:
>  >>
>  >> but There's no output to the files :-(
>  >>
>  >> When I open the Arguments pane, as you told me
> to do,
>  >> appears selected an option that says:
>  >>
>  >
>  >My guess was that locating log4j.properties was
> the problem.  However,
>  >if you are getting logging messages to the console
> then something is
>  >configuring log4j, so either log4j.properties is
> being found or
>  >something else is configuring log4j.
>  >
>  >I would suggest  modifying your log4j.properties
> file to see if it is
>  >responsible for your configuration.  If you make
> the following change:
>  >
>  >-log4j.logger.co.com=ERROR,ap1,ap2
>  >+log4j.logger.co.com=ERROR,ap1
>  >
>  >and the console messages disappear, then your
> log4j.properties file is
>  >being found.
>  >
>  >If your log4j.properties file is being found, I
> would try using
>  >FileAppender instead of DailyRollingFileAppender
> and absolute paths
>  >instead of relative paths, for example:
>  >
> 
>
>-log4j.appender.ap1=org.apache.log4j.DailyRollingFileAppender
>  >-log4j.appender.ap1.DatePattern='.'yyyy-MM-dd
>  >-log4j.appender.ap1.File=logSEMC.txt
>  >-log4j.appender.ap1.threshold=DEBUG
>  >
>  >+log4j.appender.ap1=org.apache.log4j.FileAppender
>  >+log4j.appender.ap1.File=/tmp/logSEMC.txt
>  >
>  >> Use default working directory
>  >>
>  >> If I deselect that checkbox, appears this:
>  >>
>  >> ${workspace_loc:AplicacionSEMC}
>  >>
>  >> Is this OK? I tryed both options but none
> worked. What
>  >> could you recommend me?
>  >>
>  >
>  >
>  >You should be able to specify an absolute path
> like:
>  >"/home/username/workspace/myproject" in that field
> or use the Browse
>  >button next to the field to invoke an directory
> selection box.  The
>  >behavior may be different between platforms, but
> works for me on Mac
>  >OS/X.  However, this suggestion assumed that the
> problem was finding
>  >your log4j.properties file.
>  >
>  >
>  >
>  >
>  >
> 
>
>---------------------------------------------------------------------
>  >To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
>  >For additional commands, e-mail:
> log4j-user-help@logging.apache.org
>  >
>  >  
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
>  


		
______________________________________________ 
Renovamos el Correo Yahoo!: ¡250 MB GRATIS! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

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


Re: Loading configuration file

Posted by Jacob Kjome <ho...@visi.com>.
And don't forget that if log4j.xml is in some directory on the classpath as 
well, it will get used in preference to log4j.properties.  I suggest moving 
to log4j.xml if at all possible.

Jake

At 04:57 PM 1/3/2005 -0600, you wrote:
 >
 >On Jan 3, 2005, at 3:47 PM, Johnny Gonzalez wrote:
 >
 >>
 >> Hello Arnold,
 >>
 >> I Followed your recommendations, but it still doesn't
 >> work. But for example when I make a:
 >>
 >> log.error("Variables");
 >>
 >> I'm receiving messages in the console like this:
 >>
 >> ERROR [main] (SemcControlador.java:280) - Variables:
 >>
 >> but There's no output to the files :-(
 >>
 >> When I open the Arguments pane, as you told me to do,
 >> appears selected an option that says:
 >>
 >
 >My guess was that locating log4j.properties was the problem.  However,
 >if you are getting logging messages to the console then something is
 >configuring log4j, so either log4j.properties is being found or
 >something else is configuring log4j.
 >
 >I would suggest  modifying your log4j.properties file to see if it is
 >responsible for your configuration.  If you make the following change:
 >
 >-log4j.logger.co.com=ERROR,ap1,ap2
 >+log4j.logger.co.com=ERROR,ap1
 >
 >and the console messages disappear, then your log4j.properties file is
 >being found.
 >
 >If your log4j.properties file is being found, I would try using
 >FileAppender instead of DailyRollingFileAppender and absolute paths
 >instead of relative paths, for example:
 >
 >-log4j.appender.ap1=org.apache.log4j.DailyRollingFileAppender
 >-log4j.appender.ap1.DatePattern='.'yyyy-MM-dd
 >-log4j.appender.ap1.File=logSEMC.txt
 >-log4j.appender.ap1.threshold=DEBUG
 >
 >+log4j.appender.ap1=org.apache.log4j.FileAppender
 >+log4j.appender.ap1.File=/tmp/logSEMC.txt
 >
 >> Use default working directory
 >>
 >> If I deselect that checkbox, appears this:
 >>
 >> ${workspace_loc:AplicacionSEMC}
 >>
 >> Is this OK? I tryed both options but none worked. What
 >> could you recommend me?
 >>
 >
 >
 >You should be able to specify an absolute path like:
 >"/home/username/workspace/myproject" in that field or use the Browse
 >button next to the field to invoke an directory selection box.  The
 >behavior may be different between platforms, but works for me on Mac
 >OS/X.  However, this suggestion assumed that the problem was finding
 >your log4j.properties file.
 >
 >
 >
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >  


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


Re: Loading configuration file

Posted by Johnny Gonzalez <jo...@yahoo.es>.
Hello Arnold,

Thanks a lot for your help it was very useful. I have
several jar files that I need to invoke some services
from my server (jboss), and I note that one of those
jar files has a configuration file for log4j in the
server, so when I tryed to lot messages in my
application it was using the configuration file in the
server.

Now I'm using this technique:

PropertyConfigurator logProperties = new
PropertyConfigurator();
		  logProperties.configure("conf/log4j.properties");

And now I am completely sure log4j is using this
configuration file.

Thanks a lot again,
Johnny

 --- Curt Arnold <ca...@apache.org> escribió: 
> 
> On Jan 3, 2005, at 3:47 PM, Johnny Gonzalez wrote:
> 
> >
> > Hello Arnold,
> >
> > I Followed your recommendations, but it still
> doesn't
> > work. But for example when I make a:
> >
> > log.error("Variables");
> >
> > I'm receiving messages in the console like this:
> >
> > ERROR [main] (SemcControlador.java:280) -
> Variables:
> >
> > but There's no output to the files :-(
> >
> > When I open the Arguments pane, as you told me to
> do,
> > appears selected an option that says:
> >
> 
> My guess was that locating log4j.properties was the
> problem.  However, 
> if you are getting logging messages to the console
> then something is 
> configuring log4j, so either log4j.properties is
> being found or 
> something else is configuring log4j.
> 
> I would suggest  modifying your log4j.properties
> file to see if it is 
> responsible for your configuration.  If you make the
> following change:
> 
> -log4j.logger.co.com=ERROR,ap1,ap2
> +log4j.logger.co.com=ERROR,ap1
> 
> and the console messages disappear, then your
> log4j.properties file is 
> being found.
> 
> If your log4j.properties file is being found, I
> would try using 
> FileAppender instead of DailyRollingFileAppender and
> absolute paths 
> instead of relative paths, for example:
> 
>
-log4j.appender.ap1=org.apache.log4j.DailyRollingFileAppender
> -log4j.appender.ap1.DatePattern='.'yyyy-MM-dd
> -log4j.appender.ap1.File=logSEMC.txt
> -log4j.appender.ap1.threshold=DEBUG
> 
> +log4j.appender.ap1=org.apache.log4j.FileAppender
> +log4j.appender.ap1.File=/tmp/logSEMC.txt
> 
> > Use default working directory
> >
> > If I deselect that checkbox, appears this:
> >
> > ${workspace_loc:AplicacionSEMC}
> >
> > Is this OK? I tryed both options but none worked.
> What
> > could you recommend me?
> >
> 
> 
> You should be able to specify an absolute path like:
> 
> "/home/username/workspace/myproject" in that field
> or use the Browse 
> button next to the field to invoke an directory
> selection box.  The 
> behavior may be different between platforms, but
> works for me on Mac 
> OS/X.  However, this suggestion assumed that the
> problem was finding 
> your log4j.properties file.
> 
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
>  


		
______________________________________________ 
Renovamos el Correo Yahoo!: ¡250 MB GRATIS! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

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


Re: Loading configuration file

Posted by Curt Arnold <ca...@apache.org>.
On Jan 3, 2005, at 3:47 PM, Johnny Gonzalez wrote:

>
> Hello Arnold,
>
> I Followed your recommendations, but it still doesn't
> work. But for example when I make a:
>
> log.error("Variables");
>
> I'm receiving messages in the console like this:
>
> ERROR [main] (SemcControlador.java:280) - Variables:
>
> but There's no output to the files :-(
>
> When I open the Arguments pane, as you told me to do,
> appears selected an option that says:
>

My guess was that locating log4j.properties was the problem.  However, 
if you are getting logging messages to the console then something is 
configuring log4j, so either log4j.properties is being found or 
something else is configuring log4j.

I would suggest  modifying your log4j.properties file to see if it is 
responsible for your configuration.  If you make the following change:

-log4j.logger.co.com=ERROR,ap1,ap2
+log4j.logger.co.com=ERROR,ap1

and the console messages disappear, then your log4j.properties file is 
being found.

If your log4j.properties file is being found, I would try using 
FileAppender instead of DailyRollingFileAppender and absolute paths 
instead of relative paths, for example:

-log4j.appender.ap1=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.ap1.DatePattern='.'yyyy-MM-dd
-log4j.appender.ap1.File=logSEMC.txt
-log4j.appender.ap1.threshold=DEBUG

+log4j.appender.ap1=org.apache.log4j.FileAppender
+log4j.appender.ap1.File=/tmp/logSEMC.txt

> Use default working directory
>
> If I deselect that checkbox, appears this:
>
> ${workspace_loc:AplicacionSEMC}
>
> Is this OK? I tryed both options but none worked. What
> could you recommend me?
>


You should be able to specify an absolute path like: 
"/home/username/workspace/myproject" in that field or use the Browse 
button next to the field to invoke an directory selection box.  The 
behavior may be different between platforms, but works for me on Mac 
OS/X.  However, this suggestion assumed that the problem was finding 
your log4j.properties file.





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


Re: Loading configuration file

Posted by Johnny Gonzalez <jo...@yahoo.es>.
Hello Arnold,

I Followed your recommendations, but it still doesn't
work. But for example when I make a:

log.error("Variables");

I'm receiving messages in the console like this:

ERROR [main] (SemcControlador.java:280) - Variables:

but There's no output to the files :-(

When I open the Arguments pane, as you told me to do,
appears selected an option that says:

Use default working directory

If I deselect that checkbox, appears this:

${workspace_loc:AplicacionSEMC}

Is this OK? I tryed both options but none worked. What
could you recommend me?

Thanks a lot,
Johnny

 --- Curt Arnold <ca...@apache.org> escribió: 
> 
> On Jan 3, 2005, at 12:46 PM, Johnny Gonzalez wrote:
> 
> > Hello,
> >
> > I still have no success with log4j. I downloaded
> > 1.2.9, and renamed my configuration file to
> > log4j.properties but it's not creating any log in
> the
> > log files. What can be wrong?
> >
> > - I'm using eclipse 3.0.
> > - I tryed with the log files in the same directory
> of
> > my configuration file but doesn't work.
> > - my log4j.properties is into the root of the
> project
> > - my log4j configuration file looks like this:
> >
> 
> You might check the working directory for your Debug
> or Run 
> configuration to see if it is set to the location of
> your 
> log4j.properties file.  Select Run/Run... or
> Run/Debug... from the 
> Eclipse menu and then select the "Arguments" pane. 
> If that looks okay, 
> you could try explicitly stating the location of the
> configuration file 
> by adding -Dlog4j.configuration=FILENAME to the VM
> arguments.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
>  


		
______________________________________________ 
Renovamos el Correo Yahoo!: ¡250 MB GRATIS! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

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


Re: Loading configuration file

Posted by Curt Arnold <ca...@apache.org>.
On Jan 3, 2005, at 12:46 PM, Johnny Gonzalez wrote:

> Hello,
>
> I still have no success with log4j. I downloaded
> 1.2.9, and renamed my configuration file to
> log4j.properties but it's not creating any log in the
> log files. What can be wrong?
>
> - I'm using eclipse 3.0.
> - I tryed with the log files in the same directory of
> my configuration file but doesn't work.
> - my log4j.properties is into the root of the project
> - my log4j configuration file looks like this:
>

You might check the working directory for your Debug or Run 
configuration to see if it is set to the location of your 
log4j.properties file.  Select Run/Run... or Run/Debug... from the 
Eclipse menu and then select the "Arguments" pane.  If that looks okay, 
you could try explicitly stating the location of the configuration file 
by adding -Dlog4j.configuration=FILENAME to the VM arguments.


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