开发者

In a web app, is it wise to give log files ".txt" suffix?

I am building a lo开发者_如何学JAVAgging mechanism in a web application.

Being a Windows man, I tend to give files with textual content the .txt ending. The suffix is automatically registered to be opened in a text editor in any Windows environment, and is just a nice convention.

The app is going to be redistributed, and running mostly on Linux, though. The Linux convention for log files is .log.

Is there any good reason on the Linux end, besides convention, why I should use .log? Any filters, real-life applications that could become relevant and that will work only with a .log suffix?

Or can I merrily call it error_log.txt?


As Itay correctly states, you can give file names whatever extension you choose on Linux. File extensions are a Windows-only concept; Linux uses something called magic numbers to identify file type. Type file filename and replace filename with whatever filename you want to look at and you'll see what I mean. For example /usr/bin/perl doesn't have the .exe extension it would have on Windows. As an example:

root$: file /var/log/httpd/access_log
access_log: ASCII text

That said, for Windows/Linux interoperability you might consider using an extension like .log as Linux really doesn't care, and registering that extension with your editor of choice under Windows to make your life easier. Just note when you write log files under Linux you're going to be using Unix-style line endings, not Windows ones, so notepad.exe won't display the log file properly. I use notepad++ when I'm on Windows.


On linux you can call it what ever you want, event without postfix or use several of those.. Just make sure it is created outside the web root directory, so no curious eyes can see it.


you can call it any name you name, but its more intuitive if you give it some name you can see and know straight away and/or for the convenience of finding/sorting them in future. In your example, error_log.txt is quite intuitive. One will know its an error log file in text format. Of course you can also name it using time stamp for archive and easier to search for it later on.


.log is universal, it's read plain text by all OSes by default, so there really should be no problem as long as your throwing strings in that file.


Do note that in Windows, .log is automatically registered to open with notepad in (at least) the NT family and forward. Microsoft itself does use .log for its log files (Windows update, installer log etc.) so it is as much (or even more) convention on Windows as it is on Linux.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜