Reputation: 1629
Right now, I use log4r for logger in Rails to print file name and line number:
======== config/log4r.yml ========
log4r_config:
# define all loggers:
loggers:
- name : rails
level : DEBUG
trace : 'true'
outputters :
- console
# define all outputters (incl. formatters)
outputters:
- type: StdoutOutputter
name: console
formatter:
date_pattern: '%Y-%m-%d %H:%M:%S'
pattern : '%d %l %t : %m'
type : PatternFormatter
However it prints file path instead of filename, and it's too long:
2015-12-23 18:05:37 INFO /Users/fudy/Workspace/RubyWorkspace/HelloWorld/app/controllers/welcome_controller.rb:3: in `index' : hello
But I want this format:
2015-12-23 18:05:37 INFO welcome_controller.rb:3: hello
Is there any solution?
Upvotes: 0
Views: 1083
Reputation: 4712
It doesn't show in the documentation but from looking at the code you can see that you should replace "t" with "T" to get only the file name.
The other option is to implement custom formatting like explained here
Upvotes: 2