在Linux中,log4j.appender.R.File的默认根目录在哪里?
在Windows中,当我使用以下文件路径时,log4j会将文件写入C:\eclipse\logs\appLog.log(我在Windows中使用eclipse作为IDE):
log4j.appender.R.File=logs/appLog.log
然后当我将jsp部署到apache tomcat时Linux服务器的日志文件存放在哪里? (我尽量避免使用绝对路径,因为我需要记住在部署到 Linux 后更改路径)提前致谢。
in windows, when I use the following File path, log4j will write the file to C:\eclipse\logs\appLog.log (I am using eclipse as the IDE in windows):
log4j.appender.R.File=logs/appLog.log
Then when I deploy the jsp to the apache tomcat in a Linux server, where does the log file go? (I try to avoid using absolute path because I will need to remember changing the path after deployed to linux) Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在应用程序中使用相对本地磁盘文件系统路径是一个非常糟糕的主意。它们将相对于“当前工作目录”,即应用程序启动时当前打开的目录。它可以无处不在,并且这完全不受您的应用程序的控制。
始终使用以
/
开头的绝对本地磁盘文件系统路径。Using relative local disk file system paths in an application is an extremely bad idea. They will be relative to the "current working directory", i.e. the directory which was currently opened when the application was started up. It can be everywhere and this is completely out of control from your application.
Always use absolute local disk file system paths starting with a leading
/
.虽然是一个老问题,但我添加了详细信息,以便未来的用户能够受益。
检查我的 git 项目,了解在多个环境中执行此操作的简单方法:
https://github.com/ varunachar/Log4J-多环境
Although an old question, I'm adding details so that future users can benefit.
Check my git project for an easy way to do it for multiple environments:
https://github.com/varunachar/Log4J-Multi-Environment