logging, rolling file, permission denied

  • Thread starter Guillaume Guillaume
  • Start date
G

Guillaume Guillaume

Hi,

I'm trying out the excellent logging 1.3.0 gem inside my rails
application. It works nicely with stdout and file appenders but I'm
unable to using the rolling file appender config. After running some
debug sessions I found out that the write fails due to i'm not sure
what, I am certain that the file path is valid, so I conclude it must
have to do with file locks...

By the way i'm running on windows XP.

The error:

Errno::EACCES Permission denied -
C:/rails_apps/fdc_psp_rails/log/development.log

The error is thrown from:

rolling_file.rb

def write( event )
str = event.instance_of?:):Logging::LogEvent) ?
@layout.format(event) : event.to_s
return if str.empty?

--> @io.flock_sh { super(str) } <--

if roll_required?
@io.flock? {
@age_fn_mtime = nil
copy_truncate if roll_required?
}
@roller.roll_files
end
end

logging is integrated in rails environment.rb config likeso:

Logging.init :debug, :info, :warn, :error, :fatal

logger = Logging.logger.root
layout = Logging.layouts.pattern:)pattern => '%d %l [%.20c] %m')
logger.add_appenders(
Logging.appenders.stdout:)layout => layout),
Logging.appenders.rolling_file(
"rolling_file",
:filename => "#{RAILS_ROOT}/log/#{RAILS_ENV}.log",
:age => 'daily',
:size => 2100000, # ~= 2mb
:layout => layout,
:level => :debug,
:safe => true
)
)
logger.level = :debug
config.logger = logger

I am using Mongrel but the rolling file also fails in webrick. The
result is that rolling_file logging level is set to :eek:ff...

Any help appreciated!
Thanks,
-Guillaume
 
A

Aldric Giacomoni

Guillaume said:
Hi,

I'm trying out the excellent logging 1.3.0 gem inside my rails
application. It works nicely with stdout and file appenders but I'm
unable to using the rolling file appender config. After running some
debug sessions I found out that the write fails due to i'm not sure
what, I am certain that the file path is valid, so I conclude it must
have to do with file locks...

Are you trying to log .. Concurrently with the Rails log, or are you
trying to replace the default Rails logger with your own?
Look at this :
http://mikenaberezny.com/2007/02/24/rails-logging-tips/

Keeping this in mind:
One important point to remember is that the logfile object does not
implicitly flush to the file by default. This means that your code must
call logfile.flush for the data to be written out. Alternatively, you
can set logfile.sync = true to turn on implicit flushing.
 
G

Guillaume Guillaume

Aldric said:
Are you trying to log .. Concurrently with the Rails log, or are you
trying to replace the default Rails logger with your own?
Look at this :
http://mikenaberezny.com/2007/02/24/rails-logging-tips/

Keeping this in mind:
One important point to remember is that the logfile object does not
implicitly flush to the file by default. This means that your code must
call logfile.flush for the data to be written out. Alternatively, you
can set logfile.sync = true to turn on implicit flushing.

I am trying to replace Rails logger with the one from logging gem. There
are no attempts to log concurrently as far as I'm aware. However my
debugging session hints at 2 competing processes trying to log to the
same rolling file. If I use the regular file appender I don't have that
exception. Only the rolling file setup throws the exception. It's not a
problem with flushing, the exception thrown causes the rolling file
appender to get turned off with appender.level = :eek:ff.
 
A

Aldric Giacomoni

Guillaume said:
I am trying to replace Rails logger with the one from logging gem. There
are no attempts to log concurrently as far as I'm aware. However my
debugging session hints at 2 competing processes trying to log to the
same rolling file. If I use the regular file appender I don't have that
exception. Only the rolling file setup throws the exception. It's not a
problem with flushing, the exception thrown causes the rolling file
appender to get turned off with appender.level = :eek:ff.

Did you write rolling_file.rb ? If not, which part of YOUR code is
calling the code that generates the error?
 
G

Guillaume Guillaume

Aldric said:
Did you write rolling_file.rb ? If not, which part of YOUR code is
calling the code that generates the error?

rolling_file.rb is part of logging gem, therefore I did not write it. It
is actually rails code that is calling the logger. The problem happens
whenever I start a mongrel instance with my rails 2.3.5 app. The
container is not a factor, the error also happens with webrick.
 
T

Tim Pease

Hi,
=20
I'm trying out the excellent logging 1.3.0 gem inside my rails
application. It works nicely with stdout and file appenders but I'm
unable to using the rolling file appender config. After running some
debug sessions I found out that the write fails due to i'm not sure
what, I am certain that the file path is valid, so I conclude it must
have to do with file locks...
=20
By the way i'm running on windows XP.
=20

Someone pointed out this thread to me just yesterday. Sorry that I =
missed it when it first popped up back around Christmas time.

I opened an issue for this problem: =
http://github.com/TwP/logging/issues/issue/4

It will be fixed in the next release of the Logging gem (sometime =
today).

Blessings,
TwP=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top