ขั้นแรกคือกำหนดว่าใน production mode นี่เราจะใช้ log level ไหน ควรใช้ตั้งแต่ warn ขึ้นไป
แต่ว่าทั้งนี้ถ้า app นั้นเป็นแบบ internet อาจจะมีพวก bot หรือผู้ใช้อื่นๆ ที่เข้า url ผิทำให้เกิด error 404 หรือ routing error ควรจะกำหนดให้ logger นั้นไม่ได้ทำการ log ส่วนที่ error 404 หรือ routing error โดนเขียนลง ApplicationController
EXCEPTIONS_NOT_LOGGED = ['ActionController::UnknownAction',
'ActionController::RoutingError']
protected
def log_error(exc)
super unless EXCEPTIONS_NOT_LOGGED.include?(exc.class.name)
end
แค่นี้ก็ไม่ทำให้ log โตเกินขนาดแล้ว
ที่มา:
http://maintainablesoftware.com/articles/rails_logging_tips
Posted by Revolution
Mon, 21 Jun 2010 04:38:49 GMT
Posted in ruby | Tags log, production, production, rails, ruby | no comments | no trackbacks