Java桌面应用程序中日志文件位置的最佳实践是什么? [英] What's the best practice for log file locations in Java desktop applications?
问题描述
我有一个Java Webstart应用程序,我希望我的日志输出转到文件。该应用程序必须适用于Mac OS X和Windows(并且在Linux和一般的Unix上工作会很好。)
I have a Java Webstart application and I want my log output to go to a file. The application must work on Mac OS X and Windows (and it'd be nice to work on Linux and generally any Unix).
我正在使用Logback。
I'm using Logback.
我应该在哪里放置我的日志文件?是否有标准代码来获取适合日志的文件位置,并为每个平台适当调整位置?
Where should I place my log files? Is there standard code to get a file location that is suitable for logs and will adjust the location appropriately for each platform?
推荐答案
我在大多数情况下会将它放在用户的本地Application Data目录中。根据您的应用程序,这可能不相关。
I would in most cases put it in the user's local Application Data directory. That might not be relevant depending on your application.
当我需要一个地方将我的日志文件放在Windows机器上时,我发现这个先前的问题是相关的:在Windows上存储应用程序日志文件
I found this earlier question relevant when I needed a place to put my logfiles on a Windows machine: Where to store an application log file on Windows
不幸的是,我不相信有一个功能可以获得每个平台的最佳位置。
Unfortunately, I don't believe there's a function to get the best location for each platform.
这篇关于Java桌面应用程序中日志文件位置的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!