java桌面程序配置log4j,在java桌面应用程序中使用log4j时如何在特定位置创建日志...

I am using log4j in Eclipse for logging messages in a java desktop application. I want that the log should be created in a specific folder (Specifically, in the folder which contains source folder 'src' and classes folder 'bin').

Is it possible to set this in log4j.properties? How to ensure that log is created at this location only?

解决方案

I would go with Saket's reply. But instead of hardcoding the location its always better to have a relative path.

If you started your application from a main method from a class called Launcher for example and this is the structure of your Eclipse Project directory:

Java Project

src

bin

Then just give your location to be

log4j.appender.R.File=./log/Logfile.log

This will create the file under a directory log:

Java Project

src

bin

log

LogFile.log

Hope you got it..

:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值