x**i 发帖数: 403 | 1 我使用 XML format的log file作为系统日志,append=true,只有一个log file.但每
次我重启系统,就会在原文件的尾巴上再加上一段format 的信息,
请问如何能在log file以存在的情况下,免除这段信息? | k***r 发帖数: 4260 | 2 索性自己写log文件内容了
【在 x**i 的大作中提到】 : 我使用 XML format的log file作为系统日志,append=true,只有一个log file.但每 : 次我重启系统,就会在原文件的尾巴上再加上一段format 的信息, : : : : 请问如何能在log file以存在的情况下,免除这段信息?
| A**o 发帖数: 1550 | 3 read java api, read java source code, and sub your class over xml formatter.
or, just use log4j which has all kind of appenders.
【在 x**i 的大作中提到】 : 我使用 XML format的log file作为系统日志,append=true,只有一个log file.但每 : 次我重启系统,就会在原文件的尾巴上再加上一段format 的信息, : : : : 请问如何能在log file以存在的情况下,免除这段信息?
| t*******e 发帖数: 684 | 4 用log4j好些,至少logging separation不是问题。 | b******y 发帖数: 9224 | 5 I'd prefer just roll your own. How hard it is to write a damn logger?
log4j I think is too complicated. I don't like those big apps where they do
everything for you.
Anyway, if I were you, I would just write it myself, nice and simple. | g*****g 发帖数: 34805 | 6 log4j is too complicated? And roll your own is simpler?
Oh, man, I don't know what to say. If all you need is some
System.out.println, it's simpler than log4j, anything beyond
that would be hard to beat log4j.
do
【在 b******y 的大作中提到】 : I'd prefer just roll your own. How hard it is to write a damn logger? : log4j I think is too complicated. I don't like those big apps where they do : everything for you. : Anyway, if I were you, I would just write it myself, nice and simple.
| b******y 发帖数: 9224 | 7
Well, I am a bit fan of writing my own stuff. Think of Google, Amazon, etc.
I don't think they use any off the shelf products to do their business.
Anyway, different point of view.
I have written a simple logger, that logs to a file and rotate per day basis
, works like a charm. It is used on a site that is accessed by tens of
thousands of people per day. So, performance is good enough.
I heard log4j might be a problem because it tries to do the classloader
itself, so, potentially, it could mes
【在 g*****g 的大作中提到】 : log4j is too complicated? And roll your own is simpler? : Oh, man, I don't know what to say. If all you need is some : System.out.println, it's simpler than log4j, anything beyond : that would be hard to beat log4j. : : do
| A**o 发帖数: 1550 | 8 log4j can be messy when you try to do things it's not designed to do.
like when you write your own appender where you are referencing
some class in turn depends on log4j initialization...
but if you are just using it, it should be fine.
.
basis
right
【在 b******y 的大作中提到】 : : Well, I am a bit fan of writing my own stuff. Think of Google, Amazon, etc. : I don't think they use any off the shelf products to do their business. : Anyway, different point of view. : I have written a simple logger, that logs to a file and rotate per day basis : , works like a charm. It is used on a site that is accessed by tens of : thousands of people per day. So, performance is good enough. : I heard log4j might be a problem because it tries to do the classloader : itself, so, potentially, it could mes
| g*****g 发帖数: 34805 | 9
.
The point of OOP is to re-use code, and Java is the best language in terms
of built-in and 3rd party api. All the big companies I know, use lots of
3rd party open source libs, it's the idea, not the implementation that makes
difference.
basis
Well, maybe you should try log4j on the same project, and compare it to your
home grown one, to get a sense which one would be better for your next
project.
right
A lot of libs would be a problem if you don't use it the way it should be
used.
But my poin
【在 b******y 的大作中提到】 : : Well, I am a bit fan of writing my own stuff. Think of Google, Amazon, etc. : I don't think they use any off the shelf products to do their business. : Anyway, different point of view. : I have written a simple logger, that logs to a file and rotate per day basis : , works like a charm. It is used on a site that is accessed by tens of : thousands of people per day. So, performance is good enough. : I heard log4j might be a problem because it tries to do the classloader : itself, so, potentially, it could mes
| b******y 发帖数: 9224 | 10 goodbug, I agree with you on the most part.
I do intent to investigate the log4j and see if I could use it for some
projects.
For not re-inventing the wheel, I think I've done the wheel (my own logger),
haha, so, reinventing the wheel is more like not to use another library
since mine works fine ;-) | k***r 发帖数: 4260 | 11 i have not used log4j before. Anyone care to explain a bit how it's better
than java logger? thanks in advance
【在 t*******e 的大作中提到】 : 用log4j好些,至少logging separation不是问题。
| t*******e 发帖数: 684 | 12
When you have more than one web apps running in the same JVM, typically, you
want to output separate logging files corresponding to individual
application. The settings of JVM logger are system properties shared by all
the apps. Consequently, you have to programmatically call the logging API
inside you web apps to differentiate the logging file names. Log4j doesn't
have the issue since its settings are loaded by a specific application
classloader.
【在 k***r 的大作中提到】 : i have not used log4j before. Anyone care to explain a bit how it's better : than java logger? thanks in advance
| k***r 发帖数: 4260 | 13 I see. Thanks!
you
all
t
【在 t*******e 的大作中提到】 : : When you have more than one web apps running in the same JVM, typically, you : want to output separate logging files corresponding to individual : application. The settings of JVM logger are system properties shared by all : the apps. Consequently, you have to programmatically call the logging API : inside you web apps to differentiate the logging file names. Log4j doesn't : have the issue since its settings are loaded by a specific application : classloader.
| s******e 发帖数: 493 | 14 the best implementation in java is using common logging api as the
abstraction layer.
then you can stuff in any logger impls compatible with that api. |
|