Search code examples
javawindowsunixlog4jgrinder

Is there an equivalent to /dev/null that will work on both Windows and Unix?


I am running a Java load simulator (via The Grinder) and have disabled much of the logging to streamline things. On Unix, my log4j file looks like the below - note file is set to /dev/null to remove extra logging for Unix and nul for Windows.

On Unix this works fine but I am trying to design an automation framework that will work on both Windows and Unix (the only difference being the shell scripts). If possible I would like to eliminate the need for this file to be different across the operating systems. Is there something I can use in place of /dev/null or nul that will work on both Unix and Windows?

<appender name="data-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
   <file>/dev/null</file>
   <!--<file>nul</file>-->
   <encoder class="net.grinder.util.logback.BufferedEchoMessageEncoder" />
   <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>${PREFIX}-data.log%i</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>1</maxIndex>
   </rollingPolicy>
   <triggeringPolicy class="net.grinder.util.logback.RollOnStartUp" />
</appender>

Solution

  • Why not just eliminate the whole appender? If it's not writing to a file, remove the entry entirely.