added new parameter "disable-file-logging" to disable logging to file.
This commit is contained in:
@@ -43,14 +43,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Validator.class.getCanonicalName()); // log output
|
private static org.slf4j.Logger LOGGER; // log output
|
||||||
|
|
||||||
private static void printUsage() {
|
private static void printUsage() {
|
||||||
System.err.println(getUsage());
|
System.err.println(getUsage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getUsage() {
|
private static String getUsage() {
|
||||||
return "Usage: --action metrics|combine|extract|a3only|ubl|validate|validateExpectInvalid|validateExpectValid|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] | [-h,--help] \r\n"
|
return "Usage: --action metrics|combine|extract|a3only|ubl|validate|validateExpectInvalid|validateExpectValid|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] [--disable-file-logging] | [-h,--help] \r\n"
|
||||||
+ " --action license display open source license and notice\n"
|
+ " --action license display open source license and notice\n"
|
||||||
+ " --action metrics\n"
|
+ " --action metrics\n"
|
||||||
+ " -d, --directory count ZUGFeRD files in directory to be scanned\n"
|
+ " -d, --directory count ZUGFeRD files in directory to be scanned\n"
|
||||||
@@ -59,6 +58,7 @@ public class Main {
|
|||||||
+ " It will start once a blank line has been entered.\n" + "\n"
|
+ " It will start once a blank line has been entered.\n" + "\n"
|
||||||
+ " Additional parameter for both count operations\n"
|
+ " Additional parameter for both count operations\n"
|
||||||
+ " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n"
|
+ " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n"
|
||||||
|
+ " [--disable-file-logging] disable logging to file.\n"
|
||||||
+ " --action extract extract Factur-X PDF to XML file\n"
|
+ " --action extract extract Factur-X PDF to XML file\n"
|
||||||
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
||||||
+ " [--source <filename>]: set input PDF file\n"
|
+ " [--source <filename>]: set input PDF file\n"
|
||||||
@@ -356,11 +356,13 @@ public class Main {
|
|||||||
options.addOption(new Option("", "out",true, "which output file to write to"));
|
options.addOption(new Option("", "out",true, "which output file to write to"));
|
||||||
options.addOption(new Option("", "no-notices",false, "suppress non-fatal errors"));
|
options.addOption(new Option("", "no-notices",false, "suppress non-fatal errors"));
|
||||||
options.addOption(new Option("", "logAppend",true, "freeform text to be appended to log messages"));
|
options.addOption(new Option("", "logAppend",true, "freeform text to be appended to log messages"));
|
||||||
|
options.addOption(new Option("", "disable-file-logging", false, "suppress logging to file"));
|
||||||
options.addOption(new Option("d", "directory",true, "which directory to operate on"));
|
options.addOption(new Option("d", "directory",true, "which directory to operate on"));
|
||||||
options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions"));
|
options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions"));
|
||||||
options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline"));
|
options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline"));
|
||||||
boolean optionsRecognized=false;
|
boolean optionsRecognized=false;
|
||||||
String action = "";
|
String action = "";
|
||||||
|
Boolean disableFileLogging = false;
|
||||||
try {
|
try {
|
||||||
cmd = parser.parse(options, args);
|
cmd = parser.parse(options, args);
|
||||||
|
|
||||||
@@ -370,6 +372,7 @@ public class Main {
|
|||||||
Boolean filesFromStdIn = cmd.hasOption("listfromstdin");//((Number)cmdLine.getParsedOptionValue("integer-option")).intValue();
|
Boolean filesFromStdIn = cmd.hasOption("listfromstdin");//((Number)cmdLine.getParsedOptionValue("integer-option")).intValue();
|
||||||
Boolean ignoreFileExt = cmd.hasOption("ignorefileextension");
|
Boolean ignoreFileExt = cmd.hasOption("ignorefileextension");
|
||||||
Boolean helpRequested = cmd.hasOption("help") || ((action!=null)&&(action.equals("help")));
|
Boolean helpRequested = cmd.hasOption("help") || ((action!=null)&&(action.equals("help")));
|
||||||
|
disableFileLogging = cmd.hasOption("disable-file-logging");
|
||||||
|
|
||||||
String sourceName = cmd.getOptionValue("source");
|
String sourceName = cmd.getOptionValue("source");
|
||||||
String sourceXMLName = cmd.getOptionValue("source-xml");
|
String sourceXMLName = cmd.getOptionValue("source-xml");
|
||||||
@@ -387,6 +390,14 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
ArrayList<FileAttachment> attachments=new ArrayList <>();
|
ArrayList<FileAttachment> attachments=new ArrayList <>();
|
||||||
|
/*
|
||||||
|
setting system property to disable FILE appender and
|
||||||
|
suppress creation of files and folders.
|
||||||
|
*/
|
||||||
|
System.setProperty("FILE_APPENDER_ENABLED", ((Boolean)(disableFileLogging==false)).toString());
|
||||||
|
|
||||||
|
LOGGER = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||||
|
|
||||||
if (helpRequested) {
|
if (helpRequested) {
|
||||||
printHelp();
|
printHelp();
|
||||||
optionsRecognized=true;
|
optionsRecognized=true;
|
||||||
|
|||||||
@@ -1,37 +1,38 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<target>System.err</target>
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<if condition='!isDefined("disable-file-logging")'>
|
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<then>
|
<target>System.err</target>
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- Daily rollover -->
|
|
||||||
<fileNamePattern>log/ZUV-%d{yyyy-MM}.log</fileNamePattern>
|
|
||||||
|
|
||||||
<!-- Keep 5 years worth of history -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
</then>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<!-- Configure so that it outputs to both console and log file -->
|
<if condition='property("FILE_APPENDER_ENABLED").contains("true")'>
|
||||||
<root level="INFO">
|
<then>
|
||||||
<if condition='!isDefined("disable-file-logging")'>
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender" >
|
||||||
<then>
|
<!--<appender name="FILE" class="org.mustangproject.commandline.LazyRollingFileAppender" >-->
|
||||||
<appender-ref ref="FILE" />
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
</then>
|
<!-- Daily rollover -->
|
||||||
|
<fileNamePattern>log/ZUV-%d{yyyy-MM}.log</fileNamePattern>
|
||||||
|
|
||||||
|
<!-- Keep 5 years worth of history -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
</then>
|
||||||
</if>
|
</if>
|
||||||
<appender-ref ref="STDERR" />
|
|
||||||
</root>
|
<!-- Configure so that it outputs to both console and log file -->
|
||||||
|
<root level="INFO">
|
||||||
|
<if condition='property("FILE_APPENDER_ENABLED").contains("true")'>
|
||||||
|
<then>
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
<appender-ref ref="STDERR" />
|
||||||
|
</root>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Reference in New Issue
Block a user