Redian新闻
>
when I run junit test, how can I log the java log to a file?
avatar
when I run junit test, how can I log the java log to a file?# Programming - 葵花宝典
c*i
1
在准备申请waiver的材料,发现大使馆的网页上要求提供“申请豁免时尚具在美半年以
上有效停留”的证明。这个要怎么证明呢?是不是提供DS表就可以了呢?
多谢多谢!
avatar
m*g
2
我F-1在美国读书9年,去年OPT转J-1博士后,这边J-1学校没有扣税. 请问我能不能享
受J-1免税的待遇。万分感谢。
avatar
T*m
3
日常使用,以处理数据为主,有时候可能会画一些简单的图,不打游戏
看了两款T400
7417是集成显卡,Intel Graphics Media Accelerator 4500MHD with vPro
不过我听有人说这一款机器显卡性能不佳……
另外一款2764是独立显卡,ATI Mobility Radeon 3470 with 256MB
其它配置一样的话,前者比后者要便宜$40-50
请问有必要买独立显卡的机器吗?谢谢大家!
avatar
l*n
4
when I run junit test, how can I log the java log to a file? the log is only
logged to a file when running inside glassfish
avatar
s*m
5


【在 c******i 的大作中提到】
: 在准备申请waiver的材料,发现大使馆的网页上要求提供“申请豁免时尚具在美半年以
: 上有效停留”的证明。这个要怎么证明呢?是不是提供DS表就可以了呢?
: 多谢多谢!

avatar
S*I
6
不能

【在 m*******g 的大作中提到】
: 我F-1在美国读书9年,去年OPT转J-1博士后,这边J-1学校没有扣税. 请问我能不能享
: 受J-1免税的待遇。万分感谢。

avatar
d*n
7
都差不多吧。后者好一点。
avatar
c*a
8
slf4j行不行
avatar
n*y
9
不打游戏,没必要独显,热的厉害
不过有独显也可以切换到集成显卡用,所以买独显似乎也没什么坏处
avatar
g*g
10
You can always use log4j and configure appender to both console and file.

only

【在 l**********n 的大作中提到】
: when I run junit test, how can I log the java log to a file? the log is only
: logged to a file when running inside glassfish

avatar
a*p
11
独显用的电源适配器要大一点
avatar
l*n
12
where should I put the log4j configuration file? in the resources folder of
the java source or test resources folder?

【在 g*****g 的大作中提到】
: You can always use log4j and configure appender to both console and file.
:
: only

avatar
g*g
13
It needs to be in classpath, that's all.

of

【在 l**********n 的大作中提到】
: where should I put the log4j configuration file? in the resources folder of
: the java source or test resources folder?

avatar
l*n
14
java.util.logging.Logger' is already defined in a single-type import
I found I couldn't switch to log4j.
avatar
l*n
15
in the code, I set up like this:
private static void setupLogger(){
m_log.setLevel(Level.ALL);
try {
FileHandler fhandler = new FileHandler("E:\logs\service.log");
SimpleFormatter sformatter = new SimpleFormatter();
fhandler.setFormatter(sformatter);
m_log.addHandler(fhandler);
} catch (IOException ex) {
m_log.log(Level.SEVERE, ex.getMessage(), ex);
} catch (SecurityException ex) {
m_log.log(Level.SEVERE, ex.getMessage(), ex);
}
}
static {
setupLogger();
}
// but then how I know it is production or unit testing? how to enable
logging globally?
avatar
l*n
16
I added the logging.properties to classpath, it is not working.
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=logs/jetty.log
# Write 10MB before rotating this file
java.util.logging.FileHandler.limit=10000000
# Number of rotating files to be used
java.util.logging.FileHandler.count=4
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
.level=INFO
avatar
z*e
17
前面说了log4j
我建议上aspectj
如果你会用的话,就可以很容易滴将log代码和真正逻辑代码分离
avatar
l*n
18
我们是个小公司,没有什么framework,已经用了java.util.logging.Logger, 还可以
用log4j吗? 怎么set up aspectj? 怎么分离log和真正的代码?log on method entry
point? what about to log some business logic inside the method?
avatar
l*n
19
I don't understand
Logger.getLogger(getClass().getName())
it seems creating so many logger is unnecessary. why not keep only one
Logger?
coz then it only has one place to add the Handler:
m_log.addHandler(fhandler);
otherwise it has to go to so many different logger and for each one, add the
FileHandler.
I am confused of Java.
avatar
l*n
20
there should be a global logger:
static public void setup() throws IOException {
// Get the global logger to configure it
Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
logger.setLevel(Level.INFO);
fileTxt = new FileHandler("Logging.txt");
fileHTML = new FileHandler("Logging.html");
// Create txt Formatter
formatterTxt = new SimpleFormatter();
fileTxt.setFormatter(formatterTxt);
logger.addHandler(fileTxt);
// Create HTML Formatter
formatterHTML = new MyHtmlFormatter();
fileHTML.setFormatter(formatterHTML);
logger.addHandler(fileHTML);
}
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。