farnetto / log4jconverter

Converts log4j.xml into log4j2.xml
MIT License
8 stars 15 forks source link

filename missing #5

Open djwhite81 opened 1 week ago

djwhite81 commented 1 week ago

Jun 28, 2024 2:21:12 PM freemarker.log._JULLoggerFactory$JULLogger error SEVERE: Error executing FreeMarker template FreeMarker template error: The following has evaluated to null or missing: ==> fileName [in template "log4j2.ftl" at line 18, column 58]


Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??


FTL stack trace ("~" means nesting-related):

Java stack trace (for programmers):

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:486) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:406) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:375) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:104) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:386) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:321) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) at freemarker.core.Environment.visitIteratorBlock(Environment.java:654) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:350) at freemarker.core.Environment.process(Environment.java:323) at freemarker.template.Template.process(Template.java:383) at farnetto.log4jconverter.Converter.parseXml(Converter.java:125) at farnetto.log4jconverter.Converter.convert(Converter.java:88) at farnetto.log4jconverter.Converter.main(Converter.java:72)

<?xml version="1.0" encoding="UTF-8"?>

when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${fileName} [in template "log4j2.ftl" at line 18, column 56] ---- Java stack trace (for programmers): ---- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:486) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:406) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:375) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:104) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:386) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:321) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) at freemarker.core.Environment.visitIteratorBlock(Environment.java:654) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:350) at freemarker.core.Environment.process(Environment.java:323) at freemarker.template.Template.process(Template.java:383) at farnetto.log4jconverter.Converter.parseXml(Converter.java:125) at farnetto.log4jconverter.Converter.convert(Converter.java:88) at farnetto.log4jconverter.Converter.main(Converter.java:72) Exception in thread "main" farnetto.log4jconverter.ConverterException: Cannot process template at farnetto.log4jconverter.Converter.parseXml(Converter.java:127) at farnetto.log4jconverter.Converter.convert(Converter.java:88) at farnetto.log4jconverter.Converter.main(Converter.java:72) Caused by: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> fileName [in template "log4j2.ftl" at line 18, column 58] ---- Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${fileName} [in template "log4j2.ftl" at line 18, column 56] ---- at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:486) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:406) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:375) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:104) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:386) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:321) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) at freemarker.core.Environment.visitIteratorBlock(Environment.java:654) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:344) at freemarker.core.Environment.visit(Environment.java:350) at freemarker.core.Environment.process(Environment.java:323) at freemarker.template.Template.process(Template.java:383) at farnetto.log4jconverter.Converter.parseXml(Converter.java:125) ... 2 more Disconnected from the target VM, address: '127.0.0.1:50067', transport: 'socket' Process finished with exit code 1 Thought you might want to see this, I tried to change the ftl file and that did not help. Not sure what the problem is right now. Including my xml file.
djwhite81 commented 1 week ago

The xml file did not copy properly for some reason.

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/&quot;&gt; <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%5p (%F:%L) - %m%n"/> </layout> </appender> <category name="com.alcatel_lucent.messaging.*" additivity="false"> <priority value="debug"/> <appender-ref ref="console"/> </category> <root> <priority value="debug"/> <appender-ref ref="console"/> </root>

    &lt;appender name=&quot;MailLogFile&quot; class=&quot;org.apache.log4j.RollingFileAppender&quot;&gt;
            &lt;param name=&quot;file&quot; value=&quot;build/sane.log&quot;/&gt;
            &lt;param name=&quot;MaxFileSize&quot; value=&quot;5MB&quot;/&gt;
            &lt;param name=&quot;MaxBackupIndex&quot; value=&quot;10&quot;/&gt;
            &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt;
                    &lt;param name=&quot;ConversionPattern&quot; value=&quot;%m%n&quot;/&gt;
            &lt;/layout&gt;
    &lt;/appender&gt;
    &lt;logger name=&quot;SANE&quot; additivity=&quot;false&quot;&gt;
            &lt;level value=&quot;DEBUG&quot;/&gt;
            &lt;appender-ref ref=&quot;MailLogFile&quot;/&gt;
    &lt;/logger&gt;

</log4j:configuration>