RK-BFX opened a new issue, #501:
URL: https://github.com/apache/logging-log4cxx/issues/501

   **General:** I'm building Log4cxx from sources in macOS with 
`LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER=on` with all dependencies linked 
statically in order to avoid adding any dylib (DSO) dependencies, because it 
will be used in a plug-in running in an environment I have little control over.
   
   **Set-up:** MacMini M1, 2020; macOS Sequoia 15.5, Xcode 16.2 with its 
Command Line Tools.
   
   **Build and run:**
   Get all necessary sources: <details><summary>`get-src-log4cxx.sh`</summary>
   <p>
   
   ```bash
   #!/usr/bin/env bash
   
   curl -LOR 
https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz
   tar -xf expat-2.7.1.tar.xz
   curl -LOR https://dlcdn.apache.org/apr/apr-1.7.6.tar.bz2
   tar -xf apr-1.7.6.tar.bz2
   curl -LOR https://dlcdn.apache.org/apr/apr-iconv-1.2.2.tar.bz2
   tar -xf apr-iconv-1.2.2.tar.bz2
   curl -LOR https://dlcdn.apache.org/apr/apr-util-1.6.3.tar.bz2
   tar -xf apr-util-1.6.3.tar.bz2
   curl -LOR 
https://dlcdn.apache.org/logging/log4cxx/1.4.0/apache-log4cxx-1.4.0.tar.gz
   tar -xf apache-log4cxx-1.4.0.tar.gz
   chmod -R go-w .
   ```
   </p>
   </details>
   
   Build and attempt to run tests: 
<details><summary>`build-log4cxx.sh`</summary>
   <p>
   
   ```bash
   #!/usr/bin/env bash
   
   BUILD_DIR=$(dirname "$(readlink -f "$BASH_SOURCE")")
   INSTALL_DIR=${BUILD_DIR}/Release
   mkdir -p "${INSTALL_DIR}"
   
   cmake -S expat-2.7.1 -B .gen/expat -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" 
-DEXPAT_SHARED_LIBS=OFF
   cmake --build .gen/expat --target install --config Release
   
   pushd apr-1.7.6
   ./configure --prefix "${INSTALL_DIR}"
   make -sj
   make -s install
   popd
   pushd apr-iconv-1.2.2
   ./configure --prefix "${INSTALL_DIR}" --with-apr="${INSTALL_DIR}"
   make -sj
   make -s install
   popd
   pushd apr-util-1.6.3
   ./configure --prefix "${INSTALL_DIR}" --with-apr="${INSTALL_DIR}" 
--with-apr-iconv="${INSTALL_DIR}"
   make -sj
   make -s install
   popd
   
   cmake -S apache-log4cxx-1.4.0 -B .gen/log4cxx 
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" -DBUILD_SHARED_LIBS=off 
-DAPR_STATIC=yes -DAPU_STATIC=yes -DBUILD_SITE=OFF 
-DLOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER=ON
   cmake --build .gen/log4cxx --target install --config Release --parallel
   ctest --test-dir .gen/log4cxx --config Release --output-on-failure
   ```
   </p>
   </details>
   
   **Expected:** the build and the tests succeed.
   
   **Actual:**
   The build fails with the following error:
      ```
      
[…]/Apache-log4cxx/apache-log4cxx-1.4.0/src/test/cpp/rolling/multiprocessrollingtest.cpp:351:3:
 error: use of undeclared identifier '_NSGetExecutablePath'
        351 |                 _NSGetExecutablePath(buf, &bufCount);
            |                 ^
      ```
   If I fix the compilation by inserting the following code to 
`apache-log4cxx-1.4.0/src/test/cpp/rolling/multiprocessrollingtest.cpp` after 
the `#include`s block: <details><summary>Improved from 
`apache-log4cxx-1.4.0/src/examples/cpp/com/foo/config3.cpp`</summary>
   <p>
   
      ```cpp
      #ifdef _WIN32
      #include <windows.h> // GetModuleFileName
      #elif __APPLE__
      #include <mach-o/dyld.h> // _NSGetExecutablePath
      #elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || 
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
      #include <unistd.h> // getpid
      #else
      #include <cstring> // strncpy
      #endif
      ```
   </p>
   </details>
   
   And if I then run the test: `ctest --test-dir .gen/log4cxx -C Release 
--output-on-failure -R multiprocessrollingtest`, it fails:
   <details><summary>Terminal output</summary>
   <p>
   
   ```
   Internal ctest changing into directory: […]/Apache-log4cxx/.gen/log4cxx
   Test project […]/Apache-log4cxx/.gen/log4cxx
       Start 61: multiprocessrollingtest
   1/1 Test #61: multiprocessrollingtest ..........***Failed    0.27 sec
   LC_CTYPE: en_US.UTF-8
   multiprocessrollingtest:
     test1
   log4cxx: Started
   log4cxx: DOMConfigurator configuring file input/rolling/multiprocess.xml...
   log4cxx: Loading configuration file [input/rolling/multiprocess.xml].
   log4cxx: debug attribute= "true".
   log4cxx: Threshold ="".
   log4cxx: Retreiving an instance of Test1
   log4cxx: Setting [Test1] additivity to [false].
   log4cxx: Class name: 
[org.apache.log4j.rolling.MultiprocessRollingFileAppender]
   log4cxx: Setting option name=[file], 
value=[output/rolling/multiprocess-test.log]
   log4cxx: Setting option name=[append], value=[false]
   log4cxx: Parsing rolling policy of class: 
"org.apache.log4j.rolling.FixedWindowRollingPolicy"
   log4cxx: Setting option name=[fileNamePattern], 
value=[output/rolling/multiprocess-test.%i]
   log4cxx: Setting option name=[minIndex], value=[0]
   log4cxx: Parsing triggering policy of class: 
"org.apache.log4j.rolling.FilterBasedTriggeringPolicy"
   log4cxx: Setting option name=[levelMin], value=[info]
   log4cxx: OptionConverter::toLevel: no class name specified, level=[info]
   log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"
   log4cxx: Setting option name=[ConversionPattern], value=[%m%n]
   log4cxx: Adding appender named [NUMERIC] to logger [Test1].
   log4cxx: Level value for Test1 is [debug].
   log4cxx: OptionConverter::toLevel: no class name specified, level=[debug]
   log4cxx: Test1 level set to DEBUG
   log4cxx: Retreiving an instance of Test2
   log4cxx: Setting [Test2] additivity to [false].
   log4cxx: Class name: 
[org.apache.log4j.rolling.MultiprocessRollingFileAppender]
   log4cxx: Setting option name=[file], 
value=[output/rolling/multiprocess-2.log]
   log4cxx: Setting option name=[append], value=[false]
   log4cxx: Parsing rolling policy of class: 
"org.apache.log4j.rolling.TimeBasedRollingPolicy"
   log4cxx: Setting option name=[FileNamePattern], 
value=[output/rolling/multiprocess-2-%d{yyyy-MM-dd-HH-mm-ss-SSS}.log.gz]
   log4cxx: Parsing triggering policy of class: 
"org.apache.log4j.rolling.SizeBasedTriggeringPolicy"
   log4cxx: Setting option name=[MaxFileSize], value=[1KB]
   log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"
   log4cxx: Setting option name=[ConversionPattern], value=[[%d{yyyy-MM-dd 
HH:mm:ss.SSS}] %c %-5p - %m%n]
   log4cxx: Adding appender named [DATED] to logger [Test2].
   log4cxx: Level value for Test2 is [info].
   log4cxx: OptionConverter::toLevel: no class name specified, level=[info]
   log4cxx: Test2 level set to INFO
   log4cxx: Retreiving an instance of Test3
   log4cxx: Setting [Test3] additivity to [false].
   log4cxx: Class name: 
[org.apache.log4j.rolling.MultiprocessRollingFileAppender]
   log4cxx: Setting option name=[file], 
value=[output/rolling/multiprocess-3.log]
   log4cxx: Setting option name=[append], value=[true]
   log4cxx: Parsing rolling policy of class: 
"org.apache.log4j.rolling.TimeBasedRollingPolicy"
   log4cxx: Setting option name=[FileNamePattern], 
value=[output/rolling/multiprocess-3-%d{yyyy-MM-dd-HH-mm-ss-SSS}.log]
   log4cxx: Parsing triggering policy of class: 
"org.apache.log4j.rolling.SizeBasedTriggeringPolicy"
   log4cxx: Setting option name=[MaxFileSize], value=[1KB]
   log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"
   log4cxx: Setting option name=[ConversionPattern], value=[%d{yyyy-MM-dd 
HH:mm:ss.SSS} [%t] %c %-5p - %m%n]
   log4cxx: Adding appender named [DATED-UNCOMPRESSED] to logger [Test3].
   log4cxx: Level value for Test3 is [info].
   log4cxx: OptionConverter::toLevel: no class name specified, level=[info]
   log4cxx: Test3 level set to INFO
   log4cxx: Level value for root is [info].
   log4cxx: OptionConverter::toLevel: no class name specified, level=[info]
   log4cxx: root level set to INFO
   log4cxx: Class name: [org.apache.log4j.ConsoleAppender]
   log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"
   log4cxx: Setting option name=[ConversionPattern], value=[%m%n]
   log4cxx: Adding appender named [CONSOLE] to logger [root].
     test2
     test3
     test4
   Line 218: exitCode != 0
   log4cxx: elapsed 7115
   log4cxx: messageCount 
   log4cxx: perThreadMessageCount 
   FAILED 1 of 4
   Failed Tests                                 Total   Fail    Failed %
   =======================================================================
   multiprocessrollingtest                          4      1     25.00%
     test4
   
   
   0% tests passed, 1 tests failed out of 1
   
   Total Test time (real) =   0.28 sec
   
   The following tests FAILED:
         61 - multiprocessrollingtest (Failed)
   Errors while running CTest
   ```
   </p>
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to