由买买提看人间百态

topics

全部话题 - 话题: log4j
1 2 3 下页 末页 (共3页)
m******t
发帖数: 2416
1
来自主题: Java版 - 大家愿意讨论一下log4j么

You need multiple copies of log4j.property and log4j.jar.
For tomcat logging: put one log4j.jar in /common/lib,
and log4j.properties in /common/classes.
For your web app, put one log4j.jar in your WEB-INF/lib,
and log4j.properties at wherever you want, just give the path
when you configure it in the web app.
p***p
发帖数: 559
2
Well, anyone can share his own perfect Log4J file. I only use the basic
function by Log4J, export log infos on console or in a file.
But some project can also automatically give out parameters which cause the
error ... some introduce about such feature.
A**o
发帖数: 1550
3
thanks for explaining. but i doubt the logger per thread
model would work without make your own extentions.
anyway, i don't think your request is what log4j intends to do.
and from my experience, tempering with log4j other than config is not worthy.
how about dump everything into a db using jdbc appender,
and assign each thread with a uid and log it.
and when an error occurs,
dig the db, and query on the uid, and send your email?
c***c
发帖数: 6234
4
Server Team要求我们提供一个ear file。他们可以放在不同环境里先测试。
我们有log4j,他们要求DEV server上的log file要用log_dev,QA的要用log_qa
所有log file都要放在指定的地方。比如 /app001/jas/applogs/myappname
这样myappname的folder里会有 log_dev,log_qa等等。便于他们管理
可以设置不同的 log4j.appender.FILE.File= myappname/log_env.log 吗?
server上有env property。我们upload files 就是根据这个变量决定upload到哪里的
谢谢
i**w
发帖数: 883
5
用log4j.xml时,可以引用环境变量,比如tomcat下的log路径: ${catalina.home}/
logs/myapp-${env.id}.log
用log4j.properties时,没有试过这种用法
f********h
发帖数: 149
6
I tried to use them altogether, but there is a problem.
If I invoke junit from ant, it complains the log4j system
is not properly set up. But if I run my code directly from console
using java myclass there is no problem.
Any solution to this?
e***g
发帖数: 158
7
log4j conf file should be in classpath?
f********h
发帖数: 149
8
I found my mistake. I should have put all the initialization code of log4j
in the same static group. Now it's working.
p***p
发帖数: 559
9
来自主题: Java版 - 大家愿意讨论一下log4j么
特别头疼的是,当几个不同的软件,比如Tomcat和网站都使用log4j,但是希望设置不同

policy时候,不知道如何写配置文件,放在哪里。每次都是碰运气。特别是现在使用什么
commenlogfactory之后
r*******r
发帖数: 8
10
请问如何动态改变log4j的logging level, 在程序运行的时候?
我想写一个web service 接口, 在程序运行的时候可以接受请求改变logging level
哪位大侠知道怎么做呢?
p***p
发帖数: 559
11
来自主题: Java版 - Log4j expert
I am debuging a Webservice application based on AXIS, AXIS pumps debug message
crazy. How can I let AXIS only show error debug message and my application
shows all debug mesage? About the log4j.properties
r****n
发帖数: 1088
12
有没有办法在developing的时候,比如在eclipse里运行的时候,log到console。但在
deploy到server上以后,log到file里。而且有个条件,server上没有另外一个loj4j.
xml, 只通过原本project里的log4j.xml。
c***c
发帖数: 6234
13
最后答案是没办法。
最终还是一样的log4j log file 的名字。在不同server上是一样的名字。
因为我们的app是从system env 读取server 环境的(DEV, QA,PROD)。提出这个想
法的人自己都不知道是不是能实现在DEV 上叫 appDEV.log 在QA上叫appQA.log
我就跟他说,我笨,你show给我看看怎么实现。他整了一天回信说,还是一样名字吧。
装怂有时是必要的
c******n
发帖数: 4965
14
来自主题: Programming版 - log4j 谁熟悉?
比如说, FileAppender 有很多Constructor, 当用一个PropertyConfigurator 的时
候,
log4j code 怎么决定用哪一个Constructor, 从哪里拿args to feed to Constructor
呢?
g*****g
发帖数: 34805
15
来自主题: Programming版 - log4j 谁熟悉?
通常不需要管这个问题,如果有兴趣可以去看log4j源码。

Constructor
H****S
发帖数: 1359
16
来自主题: Programming版 - 关于 Java 的 Log 轮子
取决与log4j,slf4j和logback在classpath谁比较靠前,java process会寻求log4j.
xml 或者 logback.xml来配置logger。比如说,很多人会喜欢用一个简单的bash脚本来
启动Java程序,
CLASSPATH=
for JAR in `ls lib/*.jar`; do
CLASSPATH=$JAR:$CLASSPATH
done
java -cp $CLASSPATH ...
注意这个脚本在每次运行的时候得到的CLASSPATH顺序是不定的,特别是一个程序要被
deploy到多台servers上。
这就造成了你觉得自己明明已经配置好logback.xml了,为什么log里面啥都没有呢,那
是因为程序实际上在找log4j.xml (log4j jar 来自于一个transitive dependency)。
一般这种情况下就需要做一个reverse dependency analysis找出logback或者log4j将
其彻底清除掉,或者更一劳永逸的办法:用log4j over slf4j来redirect log4j cal... 阅读全帖
Q**g
发帖数: 183
17
你高兴直接call
log4j也行啊。自定义的那个logger你愿意做成wrapper也行,愿意作成filter也行。repl
icate all log4j API也没什么大不了的,每个函数就一句话,就是call log4j的对应函
数。
还不高兴呢,就只在if判断的时候用logger,真正写log的时候直接调log4j就行,那样就
是一个filter.
作filter的话其实根cyclops proposed的方法是一样的。俺自己是倾向于做成wrapper。
这样其实更灵活。以后如果想换别掉log4j用别的包的话,改改logger类就行了,成百上
千的clie
nt程序都可以不改,只要你在logger上的interface不变
d*******r
发帖数: 3299
18
来自主题: Programming版 - 关于 Java 的 Log 轮子
最近在用 Java 做一些 server-side services,要用到 Java 做 logging 的轮子。
研究了下,发现这个轮子貌似不错 http://logging.apache.org/log4j/2.x/manual/index.html
里面有各种 local file, remote, socket, noSQL 的 log pusher
http://logging.apache.org/log4j/2.x/manual/appenders.html#Flume
http://logging.apache.org/log4j/2.x/manual/appenders.html#JMSQu
http://logging.apache.org/log4j/2.x/manual/appenders.html#NoSQL
请问 Java 大牛,你们平时用的是这个 log4j2, 还是直接用自带的 java.util.
logging ?
f*****g
发帖数: 31
19

做一个log4j写日志但级别低于配置的实验,重复1M次。然后把直接写日志变成判断log.i
Like I've said, what you need is just put isDebugEnabled() or similar
code to a log4j filter.

no matter how many classes are using log4j, if you have a good design,
just need to change several lines to switch to other logging systems.
I am not asking to do so, just want to let you know JDK logging also has
a "filter" mechanism. You can do the urgly isDebugEnabled in a plugin class.

g*****g
发帖数: 34805
20
来自主题: Java版 - 问个java logger的问题
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
t**********s
发帖数: 930
21
只找到了一个 catalina.properties:
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... 阅读全帖
l**********1
发帖数: 5204
22
来自主题: Biology版 - 生物背景学编程如何入手?
Sure
plus
文章阅读:C++面试题目分享(2)
[同主题阅读] [版面: 待字闺中] [作者:skydoor] , 2010年04月28日
http://www.mitbbs.com/article/JobHunting/31590025_0.html
more just intraGoogle mitbbs with
//www.google.com/search?ie=UTF-8%2F&oe=UTF-
8%2F&q=Collins+&btnG=Hae&as_sitesearch=utu.fi#hl=en&sclient=psy-ab&q=C%2B%2B面试题目分享
+++site%3Awww.mitbbs.com&oq=C%2B%2B面试题目分享
+++site:www.mitbbs.com&aq=f&aqi=&aql=&gs_l=serp.12...145482.154746.12.155958.30.30.0.0.0.0.111
.1844.29j1.30.0...0.0.hx9H4asD8B4&pbx=1&bav=on.2,or.r_gc.r_... 阅读全帖
j**********g
发帖数: 204
23
这是job description
1. Sr. Front End Engineer, Software Apps
Job Summary
At Apple, we work every day to create products that enrich people’s lives.
Our Advertising Platforms group makes it possible for people around the
world to easily access informative and imaginative content on their devices
while helping publishers and developers promote and monetize their work.
Our technology and services power advertising in Apple News and Search Ads
in App Store. Our platforms are highly-performant, deploye... 阅读全帖
m******t
发帖数: 2416
24


多i
If you are using any logging toolkit such as log4j, the best
practice is:
if (logger.isDebug()) {
logger.debug(...);
}
This is better than an additional static variable because it's controlled
from the same log4j config file, and it gives you finer granularity.
c*****s
发帖数: 214
25
提到的两种情况都是没有真正去写日志的情况,都没有在IO上花时间。相信我,当你的系
统处理很繁重的事情时if(isDebugEnabled())和if(DEBUG_ENABLED)有非常明显的区别。
而当进入debug模式下以后(会真正写日志的时候)assert无法像log4j那么强大和可扩展
。相比log4j或commons-logging, assert不会"works way better"。正如你说的,这时候
判断是否写日志花去的时间相比写日志是完全可以忽略的。

controlled
c*****s
发帖数: 214
26
这个又不是什么很难理解的东西。
做一个log4j写日志但级别低于配置的实验,重复1M次。然后把直接写日志变成判断log.i
sDebugEnabled(), 最后变成简单判断静态boolean的循环。
在我的机器上结果是218ms, 203ms和16ms。
log4j还在IBM的时候我们的项目就开始用它了,不能说改就改,几千个类在用它。另外我
也实在想不出什么用jdk logging的理由,改用commons-logging API还说得过去。


m******t
发帖数: 2416
27

logging
- it
And the centralized place being the log4j config file, not one of your
home-made logger class? 8-)
file
This is completely different. You are proposing your own logger class that
handles all the logging. One of the reasons people uses logging kits like
log4j is to have category/class-level logging control.
Q**g
发帖数: 183
28
这不是问题。你可以在log4j外头包一个dummy logger嘛,就是说你的logger掉
log4j不就行了,呵呵
A**o
发帖数: 1550
29
来自主题: Java版 - 问个java logger的问题
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
g*****g
发帖数: 34805
30
Use log4j, and write code like
if(logger.isDebugEnabled() {
logger.debug(xxx)
}
This is the standard practice. You can change logging level with
log4j configuration in runtime.
r*****l
发帖数: 2859
31
来自主题: Java版 - ivy问题
Find them here:
http://mvnrepository.com/artifact/log4j/log4j/1.2.16
g*****g
发帖数: 34805
32
来自主题: Programming版 - 专业c++程序员都用什么ide (转载)
log4j, slf4j之所以叫做logging framework是因为很强的可扩展性,
可以插入大量的第三方类来达到定制的目的。比如觉得blocking IO太慢,
可以换个Appender。
API通常局限于传入参数上配置,没有反射也使得C++这方面比较困难。

log4j
h**********c
发帖数: 4120
33
来自主题: Programming版 - 怎样准确测量函数执行的时间?
Let's say multi-thread. In java, LinkedConcurrentQueue can be very fast.
While you use C++. Otherwise, you can spend sometime study the source code
of log4j. It is regretful log4j is for java.
So I mentor you an architecture. For each thread you declare a local storage
, say a c++ hashmap , may not be exactly accurate. Most c++
thread can be joined. Before you join them, you can check a boolean
variable (or use semaphores), advanced Unix programming has similar example.
You don'... 阅读全帖
z*******3
发帖数: 13709
34
来自主题: Programming版 - 关于 Java 的 Log 轮子
可以吧,加多一个参数就是了
不过我觉得既然不用log4j了
就没有必要严格遵循log的level标准
我一般就是输入,输出,exception这三个凑起来用
基本上就能搞定了,around部分,也就是方法执行过程中的监控
就相对少了很多,因为如果大量使用的话
就跟log4j的结构差不多了,所以一般都是不得不用时候才写进去
debug level一般我都是依赖ide来搞
嘿嘿
H****S
发帖数: 1359
35
来自主题: Programming版 - 关于 Java 的 Log 轮子
大部分依赖冲突都是版本冲突,sbt都可以自动resolve成最新版本。log4j和logback属
于不同的library,但是都要access logging system,所以实际中有时让人很困惑。建
议用log4j over slf4,一劳永逸。用aop还要上java agent,感觉有点overkill。
w****r
发帖数: 15252
36
来自主题: Military版 - 还是马工安全
log,谁登录了,谁下载了,都log上
log4j
r*****d
发帖数: 1924
37
【 以下文字转载自 WashingtonDC 讨论区 】
发信人: Westridge (西岭), 信区: WashingtonDC
标 题: Java开发人员知识点(更新)
发信站: BBS 未名空间站 (Wed Apr 18 00:03:19 2012, 美东)
Java开发人员知识点
1.听说过James Gosling,SUN和Oracle公司。知道网上下载Java的地址,在哪讨论Java
。练习过Java在Windows下的安装和配置。知道Java应用系统中常见的几种license和JCP。了
解bytecode和Java在不同系统下可以轻松移植的原理。
2.懂得基本的Java编程和行命令格式。了解面向对象的编程思路。
几个基本点:Java基本语法和控制结构,命名和代码风格,结构化,对象封装,继承,
抽象,多态,接口,异常处理,堆空间,栈空间,垃圾回收器,static,this,
synchronized,annotations,JUnit,JDBC,JSP/servlet
Java Core APIs: java.lang,java.util,java.io,java.a... 阅读全帖
g*****g
发帖数: 34805
38
来自主题: JobHunting版 - .NET 如何申请Google或者Amazon的工作
There's a big difference between using a framework to do some simple
work and mastering it. Hibernate is a complicate one. We are not talking
about junit or log4j.
j*****7
发帖数: 10575
39
第一,去linkedin上按照语言关键字搜索,看看你要的地区,哪种语言提供的工作机会
多,级别高。例如,你可以搜索湾区50miles以内,java的职位有多少,c/c++和php的
有多少。不仅要看多少,还要看职位的级别和待遇。software engineer < sr < staff
< principal。QA < QE = UI/Front < ServerSide Engineer
第二,看你的兴趣和将来的职业发展。想做通信和系统底层的,学c/c++。想做
enterprise software,尤其是应用/商用软件的,学java。想快速搭建网站的,想做UI
的,学php/ruby/javascript。每个领域都有其独特的技术需求。
第三,语言是不是相通的?
是相通的,但你必须要起码精通一门。目前来看,一般来说,最好在这几个语言中精通
一个:java/c.c++/python/php。虽然每年都有一些新的语言冒出来,例如scala之类的
,但是想要代替主流语言,还是需要好几年的。虽说语言的语法是类似的,但是如果做
到熟练,那不写一年的代码恐怕很难做到“熟练”吧。
除此之外,... 阅读全帖
j*****7
发帖数: 10575
40
第一,去linkedin上按照语言关键字搜索,看看你要的地区,哪种语言提供的工作机会
多,级别高。例如,你可以搜索湾区50miles以内,java的职位有多少,c/c++和php的
有多少。不仅要看多少,还要看职位的级别和待遇。software engineer < sr < staff
< principal。QA < QE = UI/Front < ServerSide Engineer
第二,看你的兴趣和将来的职业发展。想做通信和系统底层的,学c/c++。想做
enterprise software,尤其是应用/商用软件的,学java。想快速搭建网站的,想做UI
的,学php/ruby/javascript。每个领域都有其独特的技术需求。
第三,语言是不是相通的?
是相通的,但你必须要起码精通一门。目前来看,一般来说,最好在这几个语言中精通
一个:java/c.c++/python/php。虽然每年都有一些新的语言冒出来,例如scala之类的
,但是想要代替主流语言,还是需要好几年的。虽说语言的语法是类似的,但是如果做
到熟练,那不写一年的代码恐怕很难做到“熟练”吧。
除此之外,... 阅读全帖
l*******n
发帖数: 35
41
来自主题: JobHunting版 - 发个j2ee的offer和经验吧
转行做j2ee的,原来谭浩强的c那个水平。自己埋头看了很多书
Accelerated c++,programming abstraction in c++,C++ primer啊,effetive c++啊;
算法类的大家说烂了的interview exposed, careercup 150,算法导论各种mitbbs上
的题,后来因为家庭和签证等各种因素综合考虑,决定不搞算法搞j2ee了。
大概一年多前开始0基础看java,主要原因之一是careercup上很多题都是java写的,不
会java完全看不懂,后来基本看懂了。
也是从斯坦福网上公开资料看起,
Introduction to Java Programming by Daniel Liang 写得很详细,所有例子基本都
有完整代码,非常适合初学者。
Think in java 非常经典的书 必看 我到现在也就来回翻了前一半多的内容几遍。
SCJP 考级的书,内容非常细,打基础不错,但是有时候会觉得过细,回字四种写法。
head first design pattern 必看 单例工厂策略代理适配器
数据库部分主要还是写写sq... 阅读全帖
G*******g
发帖数: 35
42
来自主题: JobHunting版 - Java J2EE Contractor 求Refer Project
大家好,
我是一名正在工作的Java Contractor, 从去年8月起来到现在的client做项目,已经半
年。考虑到项目4月底release,我开始着手找新项目。如果各位了解自己公司有
contractor空缺,请考虑下推荐在下。我不方便在这里告知邮箱,请发信交流技术及简
历。感激不尽!
我的基本情况:
* 学历:2012年5月Master毕业, EE专业(东部非烂校…)
* 证书:Oracle Certification Professional, Java SE 6 Programmer
Oracle Certification Expert, Java Platform, EE 6 Web Component
Developer
* 技术:Core Java, J2EE(JDBC, JPA),Frameworks(Struts,Spring,Spring MVC,
Hibernate),Database(Oracle 10/11, Toad,MySQL),Web(JSP,JavaScript,HTML,AJAX),
Web Service(SOAP,WSDL... 阅读全帖
z*******3
发帖数: 13709
43
看log4j就知道了
一般有time这个参数
其次有log的等级分级,到底是warning还是severe这些
最后一般出问题的都是error
然后error的话,你要看exception的printstacktrace
这样对于你定位问题有很大帮助
其次第二,最好能有一些instant data就是一般人为添加的各种debug info.
你也许没有server的经验
但是你debug过程序吧?
android上都有debug的分级和time point
这个问题也不说难,因为大多数人开始工作,第一件事就是看别人的代码
俗称擦屁股,而这个时候log信息实在是太重要了
r****s
发帖数: 1025
44
我老亲手设计过distributed system,每天也查log,这两个问题都是入门级的问题:
1.系统性能提高10%。啥叫性能?要么就是CPU 100%,要么就是network saturated,上
面说的啥disk I/O啥的基本不可能,任何一个网络公司的prod系统都不会到disk上取数
据。你听说亚麻直接让客户run hadoop? 这种问题就得详细追问系统的设计傻逼在什么
地方,或者你这个系统到底干的啥JB事。你不知道系统的具体结构,没法说。我觉得你
的关键就是没有追问系统的架构和CPU/Network/GC log。
2.啥叫好log?好log就是出了问题容易grep发现问题所在。那么设计logging的时候就
要仔细考虑什么地方会出问题。至于logging的效率之类无所谓log4j,logback,slf4j之
类。
b**********5
发帖数: 7881
45
来自主题: JobHunting版 - 问一道关于java type cast的面试题
别搞了, 工作时, reflection, intanceOf都用吧, 你他妈的create 一个 log4j在
一个class里, 就用XXX.class...
w**z
发帖数: 8232
46
来自主题: JobHunting版 - 问一道关于java type cast的面试题
你看懂题没有?which one is reflection here?
http://www.mkyong.com/logging/log4j-hello-world-example/
logger final static initialized once only.
b**********1
发帖数: 215
47
来自主题: JobHunting版 - Java J2EE Contractor 求Refer Project
大家好,
我是一名做过1年多工作的Java Contractor, 现在找新项目。如果各位了解自己公司有
contractor空缺,请考虑下推荐在下。我不方便在这里告知邮箱,请发信交流技术及简
历。感激不尽!
我的基本情况:
* 学历:Master毕业, EE专业
* 技术:Core Java, J2EE(JDBC, JPA),Frameworks(Struts,Spring,Spring MVC,
Hibernate),Database(Oracle 10/11, Toad,MySQL),Web(JSP,JavaScript,HTML,AJAX),
Web Service(SOAP,WSDL)Other(xml, Log4j, slf4j, JUnit, SNV, Maven, Jetty,
Agile)
* 身份:没有身份问题。
* 优势:J2EE项目上手经验;英语交流顺畅,表达能力强;技术&环境适应能力强;可
以relocate anywhere in US.
暂时就想到这些您可能需要的信息。
如果有其他问题,或需要我的简历,欢迎留言/发信!
感谢大家的关注与帮忙!
s*****r
发帖数: 43070
48
这么多帖子,还每一个提到correlation id,session context, log4j的pattern
layout,MDC这些东东
你们真是server端的码农吗
b**********1
发帖数: 215
49
来自主题: JobHunting版 - 求Java developer position
大家好,
我是一名正在工作的Java developer, 现在这份工作一直在做 fix bugs 的工作,觉得
没什么提高。请推荐Java developer position, full time or contract position.
我的基本情况:
Developer
* 技术:Core Java, J2EE(JDBC, JPA),Frameworks(Struts,Spring,Spring MVC,
Hibernate),Database(Oracle 10/11, Toad,MySQL),Web(JSP,JavaScript,HTML,AJAX),
Web Service(SOAP,WSDL)Other(xml, Log4j, slf4j, JUnit, SNV, Maven, Jetty,
Agile)
* 优势:有3年 J2EE项目上手经验;英语交流顺畅,表达能力强;技术&环境适应能力
强;可
以relocate.
暂时就想到这些您可能需要的信息。
如果有其他问题,或需要我的简历,欢迎留言/发信!
感谢大家的关注与帮忙!
m********u
发帖数: 3942
50
来自主题: JobHunting版 - Fullstack Engineer 三番
最好有绿卡~ 有兴趣请站内或者邮件 [email protected]
Job Descriptions:
Our client is looking for a motivated and talented java developer to join
our engineering team to develop the next generation programmatic advertising
system. The candidate will play a key role in the design & development of
a product suite that contributes to the evolution of the programmatic
advertising industry and his/her work will help to differentiate company
from its competitors. Prior experience in programmatic advertising or re... 阅读全帖
1 2 3 下页 末页 (共3页)