iceboxnet and Ice.LogFile

ggslayerggslayer MingYi ZhangOrganization: renren.comProject: renren data platformMember

We recently started writing IceBox sevice by C#. We found that if we put the property Ice.LogFile in config, the service caught exception and the log line has been written into the log file specified by Ice.LogFile:
!! 2017/7/20 18:28:01:242 iceboxnet.exe: error: ServiceManager: caught exception:
System.IO.IOException: file “d:\temp\hello.log” been used by another process,can not access this file.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Ice.FileLoggerI..ctor(String prefix, String file) position d:\\dist-utils\build\ice-v3.6.1-msvc2015\builds\VC120-x86-release\csharp\src\Ice\LoggerI.cs:line 130
at Ice.FileLoggerI.cloneWithPrefix(String prefix) position d:\\dist-utils\build\ice-v3.6.1-msvc2015\builds\VC120-x86-release\csharp\src\Ice\LoggerI.cs:line 135
at IceBox.ServiceManagerI.startService(String service, String entryPoint, String[] args)

After debugging the starting procedure of IceBox service, I thought i found the reason.
At LoggerI.cs:127, FileLoggerI defined as:
public FileLoggerI(string prefix, string file) :
_file = file;
_writer = new StreamWriter(new FileStream(file, FileMode.Append, FileAccess.Write, FileShare.None));

    public override Logger cloneWithPrefix(string prefix)
        return new FileLoggerI(prefix, _file);

When iceboxnet starting, Applicaion creates it's static communicator with logger, then the log file is opened, but the share mode is none. That's mean that file can not be opened again even in same process. When starting service, at ServiceManagerI.cs:590:
if("Ice.LogFile").Length == 0 &&
("Ice.UseSyslog") <= 0 ||
IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows))
initData.logger = _logger.cloneWithPrefix("Ice.ProgramName")); --> exception
cloneWithPrefix will throw exception beacuse it open the same file that already opened with share mode none.


  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff

    Hi Zhang,

    Thanks for reporting the issue, I have push a fix to use ReadWrite shared mode when open the file in the logger

Sign In or Register to comment.