java .lck文件,为什么创建.lck文件而不被Java日志删除

I am trying to implement an application level logger (webapps deployed in weblogic) - using java.util.logging .

I took the ClassLoaderLogManager from apache JULI logging system since it already implements application level logging.

So this is how my servlet code (SimpleServlet.java) looks like :

ClassLoaderLogManager ClassLoaderLogManager = new ClassLoaderLogManager () ;

String nameoflogger = SimpleServlet.class.getName() ;

boolean status = ClassLoaderLogManager .addLogger(nameoflogger);

if(status)

{

Logger logger = ClassLoaderLogManager .getLogger(nameoflogger);

logger.log(Level.FINEST, "testing SimpleServlet FINEST");

logger.log(Level.INFO, "testing SimpleServlet INFO");

logger.log(Level.SEVERE, "testing SimpleServlet SEVERE");

}

ClassLoaderLogManager .reset();

And i have the logging.properties file in java_home/jre/lib as follows

handlers= java.util.logging.FileHandler

#.level= INFO

# default file output is in user's home directory.

java.util.logging.FileHandler.pattern = %h/java_%g.log

java.util.logging.FileHandler.limit = 200

java.util.logging.FileHandler.count = 10

java.util.logging.FileHandler.append = true

java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

# Limit the message that are printed on the console to INFO and above.

#java.util.logging.ConsoleHandler.level = INFO

#java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

package8.SimpleServlet.handler = java.util.logging.FileHandler

############################################################

# Facility specific properties.

# Provides extra control for each logger.

############################################################

# For example, set the com.xyz.foo logger to only log SEVERE

# messages:

package8.SimpleServlet.level = SEVERE

So when i run the webapp - and as i access the webapp i expect java_0.log, java_1.log (log file rotation)- etc to be created. But am also seeing java0.log.lck, java1.log.lck .

The logs files are only showing SEVERE level logs as expected.

Why does this happen ? If i has creating a handler on the java code side , closing the handler would solve the issue . Buy y isnt it handled here ?

Or is it because am using am using java.util.logging.FileHandler and not org.apache.juli.FileHandler while using org.apache.juli.ClassLoaderLogManager

??

解决方案

You should expect to see lock files when the FileHandler is open. If you see them linger after the VM exits, then it is because the The FileHandler was not closed, the VM was halted or crashed while the handler shutdown hook was running, or an I/O exception took place while trying to remove them.

Looking at the config, you have a FileHandler installed on the root logger and a FileHandler installed on the SimpleServlet. Since the ClassLoaderLogManager is not being used in a JVM global way, the installed default LogManager is creating the FileHandlers before you startup your local ClassLoaderLogManager. Remove the FileHandler entries from the java_home/jre/lib comfig you have and use the ClassLoaderLogManager.readConfiguration methods to load the webapp local configuration.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值