mschilli / log4perl

Log4j Implementation For Perl
http://log4perl.com
Other
116 stars 66 forks source link

Unicode file names on Windows? #104

Open plk opened 3 years ago

plk commented 3 years ago

Using the file appender and a filename such as "пример.log" on Windows results in:

Can't open ??????.log (Invalid argument) at C:\...lib/Log/Log4perl/Appender/File.pm line 151.

It's fine with common Latin1 things but not Cyrillic etc. Is there a way to do this? In the application that uses this, I had to resort to Win32::Unicode::File in other places as this seems to be the only way to read/write files with such glyphs on Windows?

plk commented 3 years ago

I can't see an obvious way to log to a filehandle rather than a file? This would make things possible but there is no Appender for file handles? Log::Dispatch::Handle really only works with IO::Handle objects which are too low level.

mohawk2 commented 3 years ago

Have you taken a look at Log::Dispatch::File? That's available as an "appender" in log4perl. If that doesn't support Win32 unicode files, it should probably be made to do so?

plk commented 3 years ago

I tried that too but no luck - I think whatever the package, it has to use the lower-level "wide" windows APIs or it just wont' work in general.

mohawk2 commented 3 years ago

Yes, it will have to use the right API. If it doesn't do so now, then it can be made to do so via a pull request?