Log4jv2 Remove square brackets around NDC "%x" - log4j2

I would like to remove the square brackets around the Nested Diagnostic Context.
This is the current pattern I have, is there a way to remove the square brackets from output?
#Console Appender
appender.console.name=STDOUT
appender.console.type=Console
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{yyyyMMdd HHmmss.SSS} %-5p [%-8.8t] %-15.15c{1} %3x %m%n
%3x outputs [content], I would like just content.

you can use replace function like this:
%d{yyyyMMdd HHmmss.SSS} %-5p [%-8.8t] %-15.15c{1} %replace{%3x}{\[\]}{ } %m%n
See https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

Related

TeXstudio macro script : how to move the cursor to specified position?

For example, I want to write the following macro in script in TeXstudio(using QtScript):
%SCRIPT
editor.write("\\textcolor{red}{}")
After invoking this macro, I want the cursor to move into the second pair of curly braces automatically. How can I modify my code to achieve the desired effect?
%SCRIPT
txt = "\\textcolor{red}{}"
cursor.insertText(txt)
cursor.movePosition(1,cursorEnums.Left)

Log4j: Log only message string without logging className and other details

I have a java application and I am using log4j2.
I want to only log the log message without logging things like className, log level, timestamp etc.
I do see some suggestions regarding custom appender etc. But isn't there a simpler way to achieve this by just modifying the default configuration ?
Example:
log.info(" Hi This is a log message");
Desired Log statement
Hi This is a log message
You have to change config file log4j.xml
The element need to be change in that file is pattern :
if you are using log4j.properties then change corresponding element.
example of pattern element:
<PatternLayout pattern="%d [%p] %c %m%n"/>
here d id for date
p is for priority
c is for Class Name
m is fro message
n is fro separator
if you dont want any thing then remove from pattern entry.
Modified as per your requirement
<PatternLayout pattern=" %m%n"/>

normalize-space() not working

Input :
<article-id pub-id-type="doi">10.13031/aim.20152184755 </article-id>
<article-id pub-id-type="publisher-id">152184755 </article-id>
<article-id pub-id-type="other">Copyright</article-id>
XSLT:
<xsl:value-of select="concat('localfile:',
normalize-space(//article-id[#pub-id-type='publisher-id']), '.pdf')">
output:
xlink:href="localfile:152184755 .pdf (before . space also coming)
Required output:
xlink:href="localfile:152184755.pdf
I want to remove space from output.
Thanks in advance
Could that space actually be a non-breaking spacing? Check the file with a hex editor (such as HHD Software's free-hex-editor) to see if its a #160 (xA0) under the covers.

how to get specific information from one line of log file

I wanna get specific information from a log line by line,
the following is one line of log(the format is the same for the rest):
...
2010/11/22-00:00:01 - [TEST1][01.01. case1][1]
...
problem is I got nothing by using following code,
for a in str:gmatch("(%d+/%d+/%d+-%d+:%d+:%d+) - [TEST1][(%d%d.%d%d. (%C+))]") do
print(a)
end
any suggestion will be appreciated!
-, [ and ] are all magic characters in lua patterns. You need to escape them %-, %[, %].
Edit: Useful addition from #hjpotter92. . is also "magic" and should be escaped %. to match only a literal ..

What does "Error parsing XML: not well-formed" mean?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” >
I get these two errors
error: Error parsing XML: not well-formed (invalid token)
&
Open quote is expected for attribute "android:orientation" associated with an element type "LinearLayout".
Did you copy and paste that from word? Your quotes look a little funky. Sometimes word will use a different character than the expected " for double quotes. Make sure those are all consistent. Otherwise, the syntax is invalid.
Looks like you have "smart quotes" ( not simple " double quotes) around some attributes in your LinearLayout element.
There are many references that explain the differences between valid and well formed XML documents. A good starting point can be found here. There is also an online XML Validator that you can use to test XML documents.
The validator shows that you have two issues:
Some of your attribute values use an invalid quote character: ” vs. ", and
you need to close the LinearLayout tag with /> instead of just >.

Resources