Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging to file on deployed server

I would like to debug an issue on my deployed phoenix app. Is there a simple way to enable file logging?

Similar to how rails creates uat.log and production.log

like image 251
Kieran Andrews Avatar asked Oct 06 '15 03:10

Kieran Andrews


People also ask

How do I access server log files?

Double-click on the log file and it will likely open in a text program by default, or you can choose the program you'd like to use to open the file by using the right-click and “Open With” option. Another option is to use a web browser and open the server log file in HTML.

What is a server log entry?

Server log files are a raw, unfiltered look at traffic to your site. They're text files stored on your web server. Every time any browser or user-agent, Google included, requests any resource—pages, images, javascript file, whatever—from your server, the server adds a line in the log.

What is DISM log file?

DISM is the primary tool for all offline-servicing tasks. DISM runs from a command prompt from Windows PE or a running Windows operating system. If a failure occurs when executing a DISM command, the tool will provide an immediate response, and log the issue in the DISM. log file.

What is a system log file?

System Log (syslog): a record of operating system events. It includes startup messages, system changes, unexpected shutdowns, errors and warnings, and other important processes. Windows, Linux, and macOS all generate syslogs.


1 Answers

I fixed this by using this library:

https://github.com/onkel-dirtus/logger_file_backend

I added it to my mix.exs

{:logger_file_backend, "0.0.4"}

And then added this to my environment config (dev.exs and prod.exs):

config :logger, format: "[$level] $message\n",
  backends: [{LoggerFileBackend, :error_log}, :console]

config :logger, :error_log,
  path: "log/error.log",
  level: :error

More information can be found in the Logger docs.

like image 85
Kieran Andrews Avatar answered Sep 28 '22 11:09

Kieran Andrews