You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by tomoya_sueyoshi <to...@yahoo.co.jp> on 2004/04/15 16:27:38 UTC

RollingFileAppender does not rotate log files.

Hello,

I'd like to build log4cxx into my program. However, I encountered the
problem that I mentioned at this subject. RollingFileAppender.cpp uses a
T2A macro that relies on the memory allocation by alloca() at the
following context on line 73 and 81.

rename(T2A(file.str().c_str()), T2A(target.str().c_str()));

I guess, in the rename(oldpath,newpath) function, oldpath is the same as
newpath. So, rename function does not rename correctly. Does it make
sense and does anyone have a good workaround?


F.Y.I.
My environment is
MS VC++ .net 2003 (English)
Windows XP + sp2 (English)

Tomoya,

__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/


Re: RollingFileAppender does not rotate log files.

Posted by tomoya_sueyoshi <to...@yahoo.co.jp>.
Hello Michaël ,

I confirmed that the rollOver function of RollingFileAppender works well 
with UNICODE. Thank you for your support.

 Thank you.

p.s.
Could you eliminate the following two warning?
    \log4cxx-0.9.6\src\system.cpp(76) : warning C4067: unexpected tokens 
following preprocessor directive - expected a newline
    \log4cxx-0.9.6\src\socketimpl.cpp(118) : warning C4067: unexpected 
tokens following preprocessor directive - expected a newline

//#ifdef WIN32 || defined(__hpux)
#if defined(WIN32) || defined(__hpux)

Michael CATANZARITI wrote:

> Oops !
>
> I fixed the problem :
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=78 
>
>
> Michaël
>
> tomoya_sueyoshi wrote:
>
>> Hello Michaël ,
>>
>> I checked out the latest code and test it, however it still has a 
>> problem.
>> It is because "filename" on the line 83 is not "fileName" in 
>> "rollingfileappender.cpp".
>> Could you fix and update the source code?
>>
>> Here's one of the possible modifications. (Any kind of fix that works 
>> well are welcome for me.)
>>
>>
>> ***************
>> *** 61,88 ****
>>          USES_CONVERSION;
>>          remove(T2A(file.str().c_str()));
>>
>> !         // Map {(maxBackupIndex - 1), ..., 2, 1} to 
>> {maxBackupIndex, ..., 3, 2}
>> !         for (int i = maxBackupIndex - 1; i >= 1; i--)
>>          {
>>              StringBuffer file;
>>              StringBuffer target;
>>
>> !             file << fileName << _T(".") << i;
>>              target << fileName << _T(".") << (i + 1);
>>              LogLog::debug(_T("Renaming file ") + file.str() + _T(" 
>> to ") + target.str());
>>              std::string aFileName = T2A(file.str().c_str());
>>              std::string aTarget = T2A(target.str().c_str());
>>              rename(aFileName.c_str(), aTarget.c_str());
>>          }
>> -
>> -         // Rename fileName to fileName.1
>> -         StringBuffer target;
>> -         target << fileName << _T(".") << 1;
>> -
>> -         LogLog::debug(_T("Renaming file ") + fileName + _T(" to ") 
>> + target.str());
>> -         std::string aFileName = T2A(file.str().c_str());
>> -         std::string aTarget = T2A(target.str().c_str());
>> -         rename(aFileName.c_str(), aTarget.c_str());
>>      }
>>
>>      // Open the current file up again in truncation mode
>> --- 61,83 ----
>>          USES_CONVERSION;
>>          remove(T2A(file.str().c_str()));
>>
>> !         // Map {(maxBackupIndex - 1), ..., 2, 1, 0} to 
>> {maxBackupIndex, ..., 3, 2, 1}
>> !         for (int i = maxBackupIndex - 1; i >= 0; i--)
>>          {
>>              StringBuffer file;
>>              StringBuffer target;
>>
>> !             if (i != 0) {
>> !                 file << fileName << _T(".") << i;
>> !             } else {
>> !                 file << fileName;
>> !             }
>>              target << fileName << _T(".") << (i + 1);
>>              LogLog::debug(_T("Renaming file ") + file.str() + _T(" 
>> to ") + target.str());
>>              std::string aFileName = T2A(file.str().c_str());
>>              std::string aTarget = T2A(target.str().c_str());
>>              rename(aFileName.c_str(), aTarget.c_str());
>>          }
>>      }
>>
>>      // Open the current file up again in truncation mode
>>
>>
>>  Tomoya
>>
>> Michael CATANZARITI wrote:
>>
>>> Hello Tomoya,
>>>
>>> Yes it's possible to yse log4cxx with MFC !
>>>
>>> about the rollingfileappender, I fixed the problem and committed the 
>>> correction in CVS.
>>> See 
>>> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=74 
>>>
>>> for more details.
>>>
>>> Michaël
>>>
>>> Tomoya Sueyoshi wrote:
>>>
>>>> Hello Michaël,
>>>>
>>>> Yes, I did compile with an Unicode target, because my program  is a 
>>>> dialog based application using MFC and also /Zc:wchar_t option.
>>>>
>>>> Here are my compile/link options and a piece of VC project setting.
>>>>
>>>> p.s. Is it possible to use log4cxx with MFC dialog based application?
>>>>
>>>> [compile]
>>>> /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D 
>>>> "_USRDLL" /D "DLL_EXPORTS" /D "UNICODE" /D "LOG4CXX" /D 
>>>> "LOG4CXX_DLL" /D "_WINDLL" /D "_UNICODE" /FD /EHsc /RTC1 /MDd /GS 
>>>> /Zc:wchar_t /YX"stdafx.h" /Fp".\Unicode_D/dll.pch" 
>>>> /Fo".\Unicode_D/" /Fd".\Unicode_D/" /FR".\Unicode_D/" /W3 /nologo 
>>>> /c /Zi
>>>>
>>>> [link]
>>>> /OUT:"../Bin/Unicode_D/log4cxx.dll" /INCREMENTAL:NO /NOLOGO /DLL 
>>>> /DEBUG /PDB:"../Bin/Unicode_D/log4cxx.pdb" 
>>>> /MAP:".\Unicode_D/log4cxx.map" 
>>>> /IMPLIB:"../Lib/Unicode_D/log4cxx.lib" /MACHINE:X86 Ws2_32.lib 
>>>> odbc32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib 
>>>> comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
>>>> uuid.lib odbc32.lib odbccp32.lib
>>>>
>>>> [dll.vcproj]
>>>> <Configuration
>>>>     Name="Unicode Debug|Win32"
>>>>     OutputDirectory=".\Unicode_D"
>>>>     IntermediateDirectory=".\Unicode_D"
>>>>     ConfigurationType="2"
>>>>     UseOfMFC="0"
>>>>     ATLMinimizesCRunTimeLibraryUsage="FALSE"
>>>>     CharacterSet="1">
>>>
>>>
>>>
>>>
>>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> http://bb.yahoo.co.jp/
>>
>>
>>
>

__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/


Re: RollingFileAppender does not rotate log files.

Posted by Michael CATANZARITI <mc...@free.fr>.
Oops !

I fixed the problem :
 http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=78

Michaël

tomoya_sueyoshi wrote:

> Hello Michaël ,
>
> I checked out the latest code and test it, however it still has a 
> problem.
> It is because "filename" on the line 83 is not "fileName" in 
> "rollingfileappender.cpp".
> Could you fix and update the source code?
>
> Here's one of the possible modifications. (Any kind of fix that works 
> well are welcome for me.)
>
>
> ***************
> *** 61,88 ****
>          USES_CONVERSION;
>          remove(T2A(file.str().c_str()));
>
> !         // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, 
> ..., 3, 2}
> !         for (int i = maxBackupIndex - 1; i >= 1; i--)
>          {
>              StringBuffer file;
>              StringBuffer target;
>
> !             file << fileName << _T(".") << i;
>              target << fileName << _T(".") << (i + 1);
>              LogLog::debug(_T("Renaming file ") + file.str() + _T(" to 
> ") + target.str());
>              std::string aFileName = T2A(file.str().c_str());
>              std::string aTarget = T2A(target.str().c_str());
>              rename(aFileName.c_str(), aTarget.c_str());
>          }
> -
> -         // Rename fileName to fileName.1
> -         StringBuffer target;
> -         target << fileName << _T(".") << 1;
> -
> -         LogLog::debug(_T("Renaming file ") + fileName + _T(" to ") + 
> target.str());
> -         std::string aFileName = T2A(file.str().c_str());
> -         std::string aTarget = T2A(target.str().c_str());
> -         rename(aFileName.c_str(), aTarget.c_str());
>      }
>
>      // Open the current file up again in truncation mode
> --- 61,83 ----
>          USES_CONVERSION;
>          remove(T2A(file.str().c_str()));
>
> !         // Map {(maxBackupIndex - 1), ..., 2, 1, 0} to 
> {maxBackupIndex, ..., 3, 2, 1}
> !         for (int i = maxBackupIndex - 1; i >= 0; i--)
>          {
>              StringBuffer file;
>              StringBuffer target;
>
> !             if (i != 0) {
> !                 file << fileName << _T(".") << i;
> !             } else {
> !                 file << fileName;
> !             }
>              target << fileName << _T(".") << (i + 1);
>              LogLog::debug(_T("Renaming file ") + file.str() + _T(" to 
> ") + target.str());
>              std::string aFileName = T2A(file.str().c_str());
>              std::string aTarget = T2A(target.str().c_str());
>              rename(aFileName.c_str(), aTarget.c_str());
>          }
>      }
>
>      // Open the current file up again in truncation mode
>
>
>  Tomoya
>
> Michael CATANZARITI wrote:
>
>> Hello Tomoya,
>>
>> Yes it's possible to yse log4cxx with MFC !
>>
>> about the rollingfileappender, I fixed the problem and committed the 
>> correction in CVS.
>> See 
>> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=74 
>>
>> for more details.
>>
>> Michaël
>>
>> Tomoya Sueyoshi wrote:
>>
>>> Hello Michaël,
>>>
>>> Yes, I did compile with an Unicode target, because my program  is a 
>>> dialog based application using MFC and also /Zc:wchar_t option.
>>>
>>> Here are my compile/link options and a piece of VC project setting.
>>>
>>> p.s. Is it possible to use log4cxx with MFC dialog based application?
>>>
>>> [compile]
>>> /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D 
>>> "_USRDLL" /D "DLL_EXPORTS" /D "UNICODE" /D "LOG4CXX" /D 
>>> "LOG4CXX_DLL" /D "_WINDLL" /D "_UNICODE" /FD /EHsc /RTC1 /MDd /GS 
>>> /Zc:wchar_t /YX"stdafx.h" /Fp".\Unicode_D/dll.pch" /Fo".\Unicode_D/" 
>>> /Fd".\Unicode_D/" /FR".\Unicode_D/" /W3 /nologo /c /Zi
>>>
>>> [link]
>>> /OUT:"../Bin/Unicode_D/log4cxx.dll" /INCREMENTAL:NO /NOLOGO /DLL 
>>> /DEBUG /PDB:"../Bin/Unicode_D/log4cxx.pdb" 
>>> /MAP:".\Unicode_D/log4cxx.map" 
>>> /IMPLIB:"../Lib/Unicode_D/log4cxx.lib" /MACHINE:X86 Ws2_32.lib 
>>> odbc32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib 
>>> comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
>>> uuid.lib odbc32.lib odbccp32.lib
>>>
>>> [dll.vcproj]
>>> <Configuration
>>>     Name="Unicode Debug|Win32"
>>>     OutputDirectory=".\Unicode_D"
>>>     IntermediateDirectory=".\Unicode_D"
>>>     ConfigurationType="2"
>>>     UseOfMFC="0"
>>>     ATLMinimizesCRunTimeLibraryUsage="FALSE"
>>>     CharacterSet="1">
>>
>>
>>
>>
>
> __________________________________________________
> Do You Yahoo!?
> http://bb.yahoo.co.jp/
>
>
>


Re: RollingFileAppender does not rotate log files.

Posted by tomoya_sueyoshi <to...@yahoo.co.jp>.
Hello Michaël ,

I checked out the latest code and test it, however it still has a problem.
It is because "filename" on the line 83 is not "fileName" in 
"rollingfileappender.cpp".
Could you fix and update the source code?

Here's one of the possible modifications. (Any kind of fix that works 
well are welcome for me.)


***************
*** 61,88 ****
          USES_CONVERSION;
          remove(T2A(file.str().c_str()));
 
!         // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, 
..., 3, 2}
!         for (int i = maxBackupIndex - 1; i >= 1; i--)
          {
              StringBuffer file;
              StringBuffer target;
 
!             file << fileName << _T(".") << i;
              target << fileName << _T(".") << (i + 1);
              LogLog::debug(_T("Renaming file ") + file.str() + _T(" to 
") + target.str());
              std::string aFileName = T2A(file.str().c_str());
              std::string aTarget = T2A(target.str().c_str());
              rename(aFileName.c_str(), aTarget.c_str());
          }
-
-         // Rename fileName to fileName.1
-         StringBuffer target;
-         target << fileName << _T(".") << 1;
-
-         LogLog::debug(_T("Renaming file ") + fileName + _T(" to ") + 
target.str());
-         std::string aFileName = T2A(file.str().c_str());
-         std::string aTarget = T2A(target.str().c_str());
-         rename(aFileName.c_str(), aTarget.c_str());
      }
 
      // Open the current file up again in truncation mode
--- 61,83 ----
          USES_CONVERSION;
          remove(T2A(file.str().c_str()));
 
!         // Map {(maxBackupIndex - 1), ..., 2, 1, 0} to 
{maxBackupIndex, ..., 3, 2, 1}
!         for (int i = maxBackupIndex - 1; i >= 0; i--)
          {
              StringBuffer file;
              StringBuffer target;
 
!             if (i != 0) {
!                 file << fileName << _T(".") << i;
!             } else {
!                 file << fileName;
!             }
              target << fileName << _T(".") << (i + 1);
              LogLog::debug(_T("Renaming file ") + file.str() + _T(" to 
") + target.str());
              std::string aFileName = T2A(file.str().c_str());
              std::string aTarget = T2A(target.str().c_str());
              rename(aFileName.c_str(), aTarget.c_str());
          }
      }
 
      // Open the current file up again in truncation mode


  Tomoya

Michael CATANZARITI wrote:

> Hello Tomoya,
>
> Yes it's possible to yse log4cxx with MFC !
>
> about the rollingfileappender, I fixed the problem and committed the 
> correction in CVS.
> See 
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=74 
>
> for more details.
>
> Michaël
>
> Tomoya Sueyoshi wrote:
>
>> Hello Michaël,
>>
>> Yes, I did compile with an Unicode target, because my program  is a 
>> dialog based application using MFC and also /Zc:wchar_t option.
>>
>> Here are my compile/link options and a piece of VC project setting.
>>
>> p.s. Is it possible to use log4cxx with MFC dialog based application?
>>
>> [compile]
>> /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D 
>> "_USRDLL" /D "DLL_EXPORTS" /D "UNICODE" /D "LOG4CXX" /D "LOG4CXX_DLL" 
>> /D "_WINDLL" /D "_UNICODE" /FD /EHsc /RTC1 /MDd /GS /Zc:wchar_t 
>> /YX"stdafx.h" /Fp".\Unicode_D/dll.pch" /Fo".\Unicode_D/" 
>> /Fd".\Unicode_D/" /FR".\Unicode_D/" /W3 /nologo /c /Zi
>>
>> [link]
>> /OUT:"../Bin/Unicode_D/log4cxx.dll" /INCREMENTAL:NO /NOLOGO /DLL 
>> /DEBUG /PDB:"../Bin/Unicode_D/log4cxx.pdb" 
>> /MAP:".\Unicode_D/log4cxx.map" /IMPLIB:"../Lib/Unicode_D/log4cxx.lib" 
>> /MACHINE:X86 Ws2_32.lib odbc32.lib  kernel32.lib user32.lib gdi32.lib 
>> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
>> oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
>>
>> [dll.vcproj]
>> <Configuration
>>     Name="Unicode Debug|Win32"
>>     OutputDirectory=".\Unicode_D"
>>     IntermediateDirectory=".\Unicode_D"
>>     ConfigurationType="2"
>>     UseOfMFC="0"
>>     ATLMinimizesCRunTimeLibraryUsage="FALSE"
>>     CharacterSet="1">
>
>
>

__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/


Re: RollingFileAppender does not rotate log files.

Posted by Michael CATANZARITI <mc...@free.fr>.
Hello Tomoya,

Yes it's possible to yse log4cxx with MFC !

about the rollingfileappender, I fixed the problem and committed the 
correction in CVS.
See 
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=74
for more details.

Michaël

Tomoya Sueyoshi wrote:

> Hello Michaël,
>
> Yes, I did compile with an Unicode target, because my program  is a 
> dialog based application using MFC and also /Zc:wchar_t option.
>
> Here are my compile/link options and a piece of VC project setting.
>
> p.s. Is it possible to use log4cxx with MFC dialog based application?
>
> [compile]
> /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D 
> "_USRDLL" /D "DLL_EXPORTS" /D "UNICODE" /D "LOG4CXX" /D "LOG4CXX_DLL" 
> /D "_WINDLL" /D "_UNICODE" /FD /EHsc /RTC1 /MDd /GS /Zc:wchar_t 
> /YX"stdafx.h" /Fp".\Unicode_D/dll.pch" /Fo".\Unicode_D/" 
> /Fd".\Unicode_D/" /FR".\Unicode_D/" /W3 /nologo /c /Zi
>
> [link]
> /OUT:"../Bin/Unicode_D/log4cxx.dll" /INCREMENTAL:NO /NOLOGO /DLL 
> /DEBUG /PDB:"../Bin/Unicode_D/log4cxx.pdb" 
> /MAP:".\Unicode_D/log4cxx.map" /IMPLIB:"../Lib/Unicode_D/log4cxx.lib" 
> /MACHINE:X86 Ws2_32.lib odbc32.lib  kernel32.lib user32.lib gdi32.lib 
> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
> oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
>
> [dll.vcproj]
> <Configuration
>     Name="Unicode Debug|Win32"
>     OutputDirectory=".\Unicode_D"
>     IntermediateDirectory=".\Unicode_D"
>     ConfigurationType="2"
>     UseOfMFC="0"
>     ATLMinimizesCRunTimeLibraryUsage="FALSE"
>     CharacterSet="1">



Re: RollingFileAppender does not rotate log files.

Posted by Tomoya Sueyoshi <to...@yahoo.co.jp>.
Hello Michaël,

Yes, I did compile with an Unicode target, because my program  is a 
dialog based application using MFC and also /Zc:wchar_t option.

Here are my compile/link options and a piece of VC project setting.

p.s. Is it possible to use log4cxx with MFC dialog based application?

[compile]
/Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" 
/D "DLL_EXPORTS" /D "UNICODE" /D "LOG4CXX" /D "LOG4CXX_DLL" /D "_WINDLL" 
/D "_UNICODE" /FD /EHsc /RTC1 /MDd /GS /Zc:wchar_t /YX"stdafx.h" 
/Fp".\Unicode_D/dll.pch" /Fo".\Unicode_D/" /Fd".\Unicode_D/" 
/FR".\Unicode_D/" /W3 /nologo /c /Zi

[link]
/OUT:"../Bin/Unicode_D/log4cxx.dll" /INCREMENTAL:NO /NOLOGO /DLL /DEBUG 
/PDB:"../Bin/Unicode_D/log4cxx.pdb" /MAP:".\Unicode_D/log4cxx.map" 
/IMPLIB:"../Lib/Unicode_D/log4cxx.lib" /MACHINE:X86 Ws2_32.lib 
odbc32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib 
odbccp32.lib

[dll.vcproj]
<Configuration
	Name="Unicode Debug|Win32"
	OutputDirectory=".\Unicode_D"
	IntermediateDirectory=".\Unicode_D"
	ConfigurationType="2"
	UseOfMFC="0"
	ATLMinimizesCRunTimeLibraryUsage="FALSE"
	CharacterSet="1">

  Tomoya,

Michael CATANZARITI wrote:
> Hello Tomoya,
> 
> Did you compile log4cxx with an Unicode target ?
> 
> Michaël
> 
> Selon tomoya_sueyoshi <to...@yahoo.co.jp>:
> 
> 
>>Hello,
>>
>>I'd like to build log4cxx into my program. However, I encountered the
>>problem that I mentioned at this subject. RollingFileAppender.cpp uses a
>>T2A macro that relies on the memory allocation by alloca() at the
>>following context on line 73 and 81.
>>
>>rename(T2A(file.str().c_str()), T2A(target.str().c_str()));
>>
>>I guess, in the rename(oldpath,newpath) function, oldpath is the same as
>>newpath. So, rename function does not rename correctly. Does it make
>>sense and does anyone have a good workaround?
>>
>>
>>F.Y.I.
>>My environment is
>>MS VC++ .net 2003 (English)
>>Windows XP + sp2 (English)
>>
>>Tomoya,
>>
>>__________________________________________________
>>Do You Yahoo!?
>>http://bb.yahoo.co.jp/
>>
>>
> 
> 
> 

__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/


Re: RollingFileAppender does not rotate log files.

Posted by Michael CATANZARITI <mc...@free.fr>.
Hello Tomoya,

Did you compile log4cxx with an Unicode target ?

Michaël

Selon tomoya_sueyoshi <to...@yahoo.co.jp>:

> Hello,
> 
> I'd like to build log4cxx into my program. However, I encountered the
> problem that I mentioned at this subject. RollingFileAppender.cpp uses a
> T2A macro that relies on the memory allocation by alloca() at the
> following context on line 73 and 81.
> 
> rename(T2A(file.str().c_str()), T2A(target.str().c_str()));
> 
> I guess, in the rename(oldpath,newpath) function, oldpath is the same as
> newpath. So, rename function does not rename correctly. Does it make
> sense and does anyone have a good workaround?
> 
> 
> F.Y.I.
> My environment is
> MS VC++ .net 2003 (English)
> Windows XP + sp2 (English)
> 
> Tomoya,
> 
> __________________________________________________
> Do You Yahoo!?
> http://bb.yahoo.co.jp/
> 
>