I am building a logging 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 filenameand replace filename with whatever filename you want to look at and you’ll see what I mean. For example/usr/bin/perldoesn’t have the .exe extension it would have on Windows. As an example:That said, for Windows/Linux interoperability you might consider using an extension like
.logas 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 usenotepad++when I’m on Windows.