Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should a gem store log files?

Tags:

ruby

gem

I am building a ruby gem that should output a logfile. Where is it a good practice to store log files?

I am extracting this functionality from a Rails website I am building, and there I could simply log in the log/ directory.

like image 202
FrontierPsycho Avatar asked Jun 15 '13 19:06

FrontierPsycho


People also ask

Where should log files be stored?

Logs are stored as a file on the Log Server. A separate folder is created for the logged events each hour. The log files are stored by default in the <installation directory>/data/ storage/ directory on the Log Server.

What are gem files?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

Is a log of particular action on server?

Server Log: a text document containing a record of activities related to a specific server in a specific period of time. System Log (syslog): a record of operating system events. It includes startup messages, system changes, unexpected shutdowns, errors and warnings, and other important processes.


1 Answers

Ideally, make the path configurable (.rc file, switch, rails/rack config, whatever).

If it's a Rack middleware, add the possibility to specify it in the constructor's arguments.

If no log path is provided, fallback to detecting a log directory. (I vaguely remember it being config.paths['log'] in Rails, but be sure that config actually points to something before using that in your gem if it can be used outside of Rails.)

And if all else fails, log to nowhere...

Also, allow to disable logging if you enable it by default. Not everyone wants logs.

like image 123
Denis de Bernardy Avatar answered Sep 29 '22 03:09

Denis de Bernardy