How do I create a keyvaluepair in log4j2 in a propterties file?
I know in log4j version 1 it's done like:
log4j.appender.x.additionalFields={'key': 'value'}
and the XML way for it in log4j2 is:
<KeyValuePair key="key" value="value"/>
so is way to do it for a properties file like this:
`appender.x.keyValuePair ={'key': 'value'}`
?
This is a working example of how to define a key value pair for example for the Graylog2 (GELF) appender:
appender.graylog.type=GELF
appender.graylog.name=GRAYLOG
appender.graylog.server=yourhostname
appender.graylog.includeStackTrace=true
appender.graylog.additional1.type=KeyValuePair
appender.graylog.additional1.key=yarncontainer
appender.graylog.additional1.value=containerXYZ
appender.graylog.additional2.type=KeyValuePair
appender.graylog.additional2.key=anotherKey
appender.graylog.additional2.value=anotherValue
Related
I have created my Apache Velocity template under /resources/fileTemplates/internal/myTemplateClass.vm and would like to use it through:
final JavaDirectoryServiceImpl javaDirectoryService = new JavaDirectoryServiceImpl();
javaDirectoryService.createClass(myPsiDirectory,
"MyClassname",
"myTemplateClass");
So I added the following in my plugin.xml:
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<internalFileTemplate name="myTemplateClass"/>
</extensions>
However when I run my plugin it claims that it did not find a template with the name "myTemplateClass". I assume it is cause I haven't linked to the file perse. Where should I link this?
Thanks
If you have an <internalFileTemplate> with the name of "myTemplateClass" and you want to use it to create a Java class, the template needs to be stored as fileTemplates/internal/myTemplateClass.java.ft. So you need to change the extension of your file.
I am creating a message in my route, using:
<setBody id="_setBody1">
<constant>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?&>
..........
<mes:CalendarView MaxEntriesReturned="5" StartDate="(property.DateStart)" EndDate="(property.EndDate)"/>
But property doesn't work. In log I see:
<mes:CalendarView MaxEntriesReturned="5" StartDate="(property.DateStart)" EndDate="(property.EndDate)"/>
How I can insert property in message?
It looks like you want to set some properties inside a static content of XML. I suggest using one of the templates.. such as velocity. It will allow you to do property replacement and manage the static content outside of the route (which is handy for testing and other maintenance)
Yes, i created property before:
<setProperty id="_setProperty1" propertyName="DateStart">
<groovy>new java.text.SimpleDateFormat('yyyy-MM-dd').format(request.body.getStartDate())</groovy>
</setProperty>
But i want to insert this property in content of xml, inside Apache Camel route.
I have an xml like:
<name>Mule</name>
<company>mulesoft</company>
How can I map using datamapper to get result like:
<details name="Mule" company="mulesoft" />
I tried but datamapper never shows the attributes to map.
I am using Mule 3.5.1
you need to either supply the schema or provide an example for both sides.
For example use the following as the sample source. DataMapper will generate the XSD based on the example file:
<enity>
<name>Mule</name>
<company>mulesoft</company>
</enity>
Right side do the same but use
<company>
<details name="Mule" company="mulesoft" />
</company>
Then click Create Mappings and you should see the mappings to your attributes.
I am trying to set a flag so I do something like this:
<set field="existingFound" value="false" type="Boolean"/>
but the following line prints "true" in the log:
<log message="storeProperty, existingFound (0): ${existingFound}"/>
What is the best way to set flags?
The set.#value attribute is interpreted as a Groovy String (GString) so any non-empty value will be interpreted as true. The set.#from attribute is interpreted as a Groovy expression, so simply using from="false" instead of value="false" will get the desired result.
To see the generated Groovy code from an XML actions block you can write code that will cause an error and then the script will be logged, or you can change the log4j.xml file to turn on "debug" level logging for the XmlActions class (the latest log4j.xml file in the GitHub repository has an example of this). Looking at the Groovy code generated from the XML elements is a good way to track down issues when what is happening just doesn't make sense.
One of my goals in creating the bootstrap project is to set a default log location. I would like the location to be based on the local app data folder. I cannot figure out how to reference the builtin Burn variable LocalAppDataFolder. I have found information about how to reference these variables in code, but not in the xml.
The reference to the property looks like this:
<MsiPackage SourceFile="MyInstaller.msi" LogPathVariable="[LogLocation]" />
The property is set like this:
<Variable Name="LogLocation" Value="[LocalAppDataFolder]MyLogFolder\Setup" Type="string"/>
The log output shows:
Initializing string variable 'LogLocation' to value
'[LocalAppDataFolder]MyLogFolder\Setup'
What am I missing to resolve [LocalAppDataFolder] ?
thanks in advance.
It's normal for the log output to show the un-formatted value, so that part looks correct. I think what you are missing is LogPathVariable should be specified without the brackets.
<MsiPackage SourceFile="MyInstaller.msi" LogPathVariable="LogLocation" />