简体   繁体   English

当我运行可运行的jar时未创建日志文件

[英]Log file is not created when i run my runnable jar

I have used logging in an desktop application using log4j but when i export that utility as a runnable jar then the log file is not created when i run this jar. 我曾使用log4j在桌面应用程序中进行日志记录,但是当我将该实用程序导出为可运行的jar时,则在我运行该jar时未创建日志文件。 Below is my log4j.properties file. 以下是我的log4j.properties文件。 please tell me what i am missing. 请告诉我我所缺少的。

# Log levels
log4j.rootLogger=DEBUG,CONSOLE,R
# Appender Configuration
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
# Pattern to output the caller's file name and line number
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# Rolling File Appender
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Path and file name to store the log file
log4j.appender.R.File=D:/myapp/mylog.log
log4j.appender.R.MaxFileSize=200KB
# Number of backup files
log4j.appender.R.MaxBackupIndex=2
# Layout for Rolling File Appender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n

Direct log messages to a log file 将日志消息直接定向到日志文件

log4j.appender.R.File=C:\\loging.log

Follow this tutorial to learn more about log4j usage: 请遵循本教程以了解有关log4j用法的更多信息:

http://www.mkyong.com/logging/log4j-log4j-properties-examples/ http://www.mkyong.com/logging/log4j-log4j-properties-examples/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行jar文件时不会创建Log4j Log - Log4j Log is not created when jar file run 当我将Java导出为可运行的jar文件时,不起作用 - When i export my java as runnable jar file, do not work 为什么当我将国际象棋项目作为一个可运行的jar文件运行时,我得到一个奇怪的行为,而当我在eclipse中运行它时一切正常? - Why when I run my chess project as a runnable jar file I get a strange behavior while when I run it inside eclipse everything works just fine? 从 Apple 脚本运行时,为什么我的 Runnable .jar 文件没有在终端中打印任何消息? - Why is my Runnable .jar file not printing any messages in the terminal, when run from an Apple Script? 当我尝试在服务器中运行时,Runnable Jar无法找到类 - Runnable Jar cannot find class when i try to run in my server 当我尝试将我的项目导出为可运行的 jar 文件时,我看到了这个错误 - When I try to export my project as runnable jar file I see this error 从GNOME运行时如何获取可运行.jar文件的位置 - How to get location of runnable .jar File when run from GNOME 如何在没有 Java JDK 的情况下运行 Runnable Jar 文件? - How do I run a Runnable Jar File without Java JDK? 如何在使用Eclipse创建的可运行jar中指定外部log4j2配置文件 - How to Specify External log4j2 Config File in Runnable jar Created with Eclipse 可运行的jar文件无法运行 - runnable jar file not runnable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM