1

I searched the docs, but found no answer. What is the preferred way of turning on access logging?

I expect HTTP verb, requested path, source IP address,... printed to either standard output or a log file.

All I got so far is:

Browse your REST API at http://0.0.0.0:3000/explorer
Web server listening at: http://0.0.0.0:3000/

The server responds to requests but I cannot see any logs.

I currently need to run the app using slc run (no process manager).

ideaboxer
  • 3,863
  • 8
  • 43
  • 62

2 Answers2

3

You can achieve the logs in a separate file by just passing the log file name. for example:-

slc run -d -l /tmp/file.log -p /tmp/file.pid -d

-d will detach the process from your current screen, and will run it in the background

Go through the below links, for further clarifications:- http://docs.strongloop.com/display/NODE/slc+run

http://docs.strongloop.com/display/SLC/Logging

And for choosing the correct logger:- http://docs.strongloop.com/display/SLC/Using+logging+libraries

Winston and bunyan are 2 well suited loggers, we are using bunyan and it is working really good for us.

If you want to RUN the slc in the DEBUG mode, to check all the logs, you can run using

DEBUG=* slc run
Nishant
  • 3,614
  • 1
  • 20
  • 26
  • `DEBUG=* slc run` results in somewhat of an access log. How can I achieve a more detailed log like Apache's or Nginx's default access logs? (containing IP address, time, HTTP version, browser) – ideaboxer May 27 '15 at 23:05
  • `DEBUG=* slc run` nicely enabled debug logs, thanks. – average Joe Jun 26 '15 at 14:00
2

Since loopback is based on express, you could start with something like morgan:

var morgan = require('morgan');
app.use(morgan('combined'))
Ryann Graham
  • 8,079
  • 2
  • 29
  • 32