Is it possible to change the log format in the glassfish gem? I find
the multi-line format from java.util.logging.SimpleFormatter really hard
to read, especially combined with the multi line output from Rails.
Looking at the source of glassfish gem it looks like SimpleFormatter is
hard coded. I have tried to get the gem to use a different
logger.properties without success. Has anyone had any success this way?
Looking at the latest code in the svn repo I see that there is a new
custom GlassFishLogFormatter with what looks like a much nicer handling
of the rails log. But it also looks like this formatter will only be
used for console logging. Maybe there could be a property in
glassfish.yml for selecting the formatter for the log file?
Are there any nightly builds of glassfish gem available so that I can
try the new formatter?
There is no easy way except how you would override any Java Logger. for
the
upcoming gem release its re-factored. The console logging is pretty
much
left to how a given framework (such as Rails or Rack::CommonLogger or
Sinatra etc.) would like to log. The logs in the file is the one coming
from
the framework as well as server and so has the JDK logging mixed with it
but
I think its an improvement over existing behavior.
There is no easy way except how you would override any Java Logger. for the upcoming gem release its re-factored. The console logging is pretty much left to how a given framework (such as Rails or Rack::CommonLogger or Sinatra etc.) would like to log. The logs in the file is the one coming from the framework as well as server and so has the JDK logging mixed with it but I think its an improvement over existing behavior.
class RailsLogFormatter < java.util.logging.Formatter
def format(record)
msg = record.getMessage()
if(!msg.end_with?(“\n”))
msg << “\n”
end
return msg
end
end
logger = java.util.logging.Logger.getLogger(“”)
logger.getHandlers().each do |h|
h.setFormatter(RailsLogFormatter.new)
end
That gave me a log looking just like the regular rails log. It works
well for development at least.
I haven’t tried 0.9.6.dev yet but from what I remember from the source it
does roughly the same thing but only for the console logger?
It was fixed sometime back in ver 0.9.6.dev. See http://bit.ly/6AABjE.
Extra
newline applies in this case only to the Logger emitting messages from
Rails
or Sinatra or anything running on glassfish gem.
-vivek.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.