-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Alec,

On 12/3/13, 1:12 PM, Tomcat Random wrote:
> I'm trying to implement log4j as per the instructions here
> (skipping step 5): 
> http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
> 
> Since I'm not using the Manager, I've removed the relevant logging
> lines from CATALINA_HOME/lib/log4j.properties, so it looks like
> this:
> 
> _____________________________ log4j.rootLogger=INFO, CATALINA
> 
> # Define all the appenders 
> log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender 
> log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.

This appender creates the "catalina." file, so you are doing this to
yourself.

> log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'

This will move "catalina." to "catalina..yyyy-MM-dd.log" every time
the date rolls over (actually, when the first log from the following
day is written). So, you are creating "catalina..yyyy-MM-dd.log" yourself.

"catalina.out" is impossible to avoid, because stdout *must* go
somewhere. If you want, you can set CATALINA_OUT to /dev/null but then
you might miss crucial log messages.

> log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender 
> log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.

You are creating this file. If you don't send any log messages to it,
that's your fault. If you don't want it, don't configure it.

> _____________________________
> 
> On restart, my (deleted-beforehand) logs directory looks like
> this:
> 
> /logs/catalina. /logs/catalina.2013-12-03.log /logs/catalina.out 
> /logs/cluster.2013-12-03.log /logs/localhost. 
> /logs/localhost_access_log.2013-12-03.txt 
> _____________________________

I would have expected your filenames to contain two sequential dots
before the dates because your ".File" property ends with a dot and
your ".DatePattern" begins with a dot.

> "catalina.out" has spymemcached logging info (I haven't changed
> the spymemcached  system property yet to log4j so that might be
> why).

It's also possible that spymemcached is writing directly to System.out
(or System.err). You might want to check on that. Or it may be logging
to ServletContext.log().

> "cluster.2013-12-03.log" is behaving normally. "localhost." is
> empty. And the daily access log is good.

Odd... as you have not configured such a log about. That must be
happening elsewhere.

> So, all I want is to have:
> 
> 1. one log file that rolls daily (a new file each day), with the
> date appended, that catches my own logging code in the app, based
> on a global logging level value that I can change (DEBUG, or INFO,
> or ERROR etc) as needed.

You cannot avoid catalina.out unless you do something dumb like
sending stdout to /dev/null.

> 2. Another log file that rolls daily and consolidates any other
> output of the server and app (or two separate files) and also has a
> logging level value that can be changed globally.

No problem. What you have above should work for that.

> 3. Get rid of the empty localhost. file.

Just remove the configuration for the LOCALHOST appender and that will
solve this problem.

As Konstantin suggested, you should read the documentation for log4j.
What is in the Tomcat documentation is just a suggestion to get you
started.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSn2inAAoJEBzwKT+lPKRYRq0P/RcofIzrFYmLCL+lm8H93p8J
9Efs0JgeSA0YctejCN/p3bBNFC6NkcG1ZVQ9txoksFbzEIbJU/WrfUS7FUZgPaw+
e2f+5BW90aIxKK7PkCA1opJVKj3jhIxTix9egQJrfoIGlZ+iuqkeHpevtYN8z5Dt
pcuwlq3/+r38Vh+NnaxcCBlniigja/q4u4KW9eH00XHXSRCL6Rf7labldxVf3Klf
V+hlAUimmejQ2IYYYMYuE8thcjiEPwzDPe+IMmWcy4l07jOPzFWdKMYR1HD9THo/
agW9iimx+4sC4UJn03GZ8ndEmPj6ShFS0wHcvyQWinAKqMZ9UyKqRM4YPgpJkHFu
Uhct6JAGhteZ02uSPynw6PZu6cfIcB50QR+Bf0c9/v+lJZJ/WQFhZspcCTawwMDr
hzgu9Mp4ZHYVjneOQ0pFHmV8ZcoNlXlxdjntH0JoPEj4giPzJQnW80LLQ73TftPJ
GP3swzGFZF2sLBV5fG3Faeww4wL4zhz64fKf/6r6C3nGj8/SORA+msSF4/ySr51i
jWOcuiCsjul/PDAC+cTsBOyKXJQsJZ/99p+5qeUb1wkldbI35mWUZwh1lVGQs8Pc
/kkWRESajL35kZJ7h9LXLtFt3rYtKQKzgJ9Tfvgd5zjhvLPLWxfNSTNZPl6Ys93L
xaFsE9WOURRSa/FcmeCp
=JQo2
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to