Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Logs
- ## Log levels
- From 0 to 5 in severity:
- * `debug` - for debugging purposes, only
- * `info` - an informative message
- * `warn` - this may or may not be an issue
- * `error` - this is an issue, but the application can continue running
- * `fatal` - this is and issue, and the application should halt
- * `unknown` - we don't know (?)
- A corresponding `Rails.logger.level` method exists for each of these levels.
- ## Logging important events in the application
- When writing to the log, give the developer some "breadcrumbs" to follow.
- Specify the class name and method name that is writing to the log.
- ```
- msg = "[#{self.class.name}##{__method__}] something important happened that we should log."
- Rails.logger.info(msg)
- ```
- If you are `rescue`ing, it probably makes sense to log the error, as well.
- ```
- begin
- # some code that might fail
- rescue StandardError => err
- Rails.logger.error("[#{self.class.name}##{__method__}] raised an error.")
- Rails.logger.error(err)
- # handle the error
- end
- ```
- ## Download Logs from Production
- ```
- $ scp -p ubuntu@wobbe.workbar.com:~/wobbe/current/log/* ~/path/to/wobbe/logs
- ```
- ## Searching Logs
- The following command will show you three lines before and three lines after any
- occurrence of `ClassName`.
- ```bash
- $ cat production.log | grep -B 3 -A 3 "ClassName"
- ```
Add Comment
Please, Sign In to add comment