How to disable printing the Logback pattern in log files - logback

I noticed that Logback prints the pattern that it uses to format the log entries at the top of every log file.
For instance, I see this at the top of each log file:
#logback.classic pattern: %d [%t] %-5p %c - %m%n
How can I disable this?

Setting outputPatternAsPresentationHeader to false would work. However, the issue is addressed in logback version 1.0.3 where outputPatternAsPresentationHeader is set to false by default.

Okay, I found the problem was answered on the logback-user mailing list.
I added this:
<outputPatternAsPresentationHeader>false</outputPatternAsPresentationHeader>
To the <encoder> element, below the <pattern> element, and my problem was solved!

Related

filebeat #timestamp not overwritten

I use filebeat to write logs to an elasticsearch server. My logs are in json format. Every line is a json string that looks like this
{"#timestamp": "2017-04-11T07:52:480,230", "user_id": "1", "delay": 12}
I want the #timestamp field from my logs to replace the #timestamp field that filebeat creates when reading the logs. On my kibana dashboard I always get
json_error:#timestamp not overwritten (parse error on 2017-04-11T07:52:48,230)
and end up seeing the #timestamp field created by filebeat
My filebeat conf includes those lines regarding overwriting fields
json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true
Also from my log4j conf the #timestamp field created in my logs is in ISO8601 format. Any idea what the problem is and why the #timestamp field is not overwritten?
The problem was the format of the timestamp that log4j is producing.
Filebeat expects something of the form "2017-04-11T09:38:33.365Z" it has to have to T in the middle the Z in the end and dot instead of comma before the milliseconds.
Quickest (and somewhat dirty) way I found to do that was by using the following pattern
pattern='{"#timestamp": "%d{YYYY-MM-dd}T%d{HH:mm:ss.SSS}Z"}
A similar issue can be found here. The suggested solution does not solve the filebeat issue though because it uses comma!

Vim modeline in a JSON file

I'm trying to add the following vim modeline to my global .tern-config file:
// vim: set ft=json:
{
plugins: {
...
However, the Tern server fails to start, giving the following error:
Failed to start server:
Bad JSON in /Users/XXXXX/.tern-config: Unexpected token / in JSON at position 0
I suspect the reason for this error is JSON's lack of support for comments. I should note that the same modeline in my .eslintrc file works.
How do I include a vim modeline in my .tern-config file?
If one puts an object like this
"_vim_": { "modeline": "/* vim: set ft=json noet ts=4 sw=4: */" }
as first or last entry into the top-level object list of a json file it will be used as modeline by vim (as long as the line appears close enough at the beginning or end of the file, where "close enough" means: within the number of lines that vim scans for modelines according to its 'modelines' option which defaults to 5).
Also, the object's name ("_vim_") should be carefully chosen, so that -- at best -- it is ignored by the software that uses the file as input, or -- at least -- can be ignored by the software's users (i. e., it doesn't cause any side effect that would be considered as unwanted behaviour).
You won't able to do this in the file itself. JSON does not support comments, and it's a very unforgiving syntax.
This may work in some JSON files, like .eslintrc, but in others, you will be out of luck. The stricter JSON parsers will not allow it, so it depends on which parser the tool you're using at the moment is built on.
Rather than guessing which parsers are forgiving and which aren't, you are probably better off telling Vim how to do this using an autocmd.
autocmd BufNewFile,BufRead *.tern-config set filetype=json

How to escape characters in ofbiz widget

Ofbiz: I need to display in browser, a value that comes from url parameters.
To avoid XSS attacks this value should to be escaped.
The value is set in PScreens.xml as following :
<screen name="Product">
<section>
<actions>
<set field="productId" from-field="parameters.productId"/>
</actions>
<widgets>
...
</widgets>
And is included in PForms.xml :
<field name="productId" tooltip="${uiLabelMap.ProductId} [${productId}]"><text /></field>
Initially I tried to escape the value from PForms.xml:
tooltip="${uiLabelMap.ProductId} [${productId}]"
but I did not found any solution.
Can you suggest a solution to escape the value from PScreens.xml?
<set field="productId" from-field="parameters.productId"/>
Thank You.
This is a duplicate of How to escape characters in ofbiz display-entity | XSS in Ofbiz I see no reasons to want to escape an already automatically escaped string. See https://issues.apache.org/jira/browse/OFBIZ-6506 for more information
I know now that you use an old Apache OFBiz version (pre R09.04). You can't expect to fix all the security issues on such an old version only by patching them one by one (see http://ofbiz.apache.org/download.html#vulnerabilities). So I suggest rather that you adapt your custom code to be used with a more recent version

How do I turn off certain messages in AMPL?

I have an AMPL script that involves calling "solve" on a linear program many times. The solver I'm using is MINOS. After every time it solves, it outputs:
MINOS 5.51:
"option abs_boundtol 2.220446049250313e-16;" or "option
rel_boundtol 2.220446049250313e-16;" will change deduced dual values.
Is there a way to suppress this message?
I read this in the MINOS instructions:
For invocations from AMPL's solve command or of the form
minos stub ...
(where stub.nl is from AMPL's -ob or -og output options), you can use
outlev= to control the amount and kind of output:
outlev=0 no chatter on stdout
outlev=1 only report options on stdout
outlev=2 summary file on stdout
outlev=3 log file on stdout, no solution
outlev=4 log file, including solution, on stdout
which might be relevant but I don't understand it.
I have included "option solver_msg 0;" in my script; it turns off the announcement from MINOS that it got such-and-such an optimal value with so many iterations, but it doesn't affect the message I'm asking about here.
You can redirect the remaining solver output to /dev/null (or equivalent for your system) as follows:
solve > /dev/null;
As for the message about abs_boundtol and rel_boundtol, I think you can set them to a small positive value larger than 2.220446049250313e-16 to make the message go away. Note that this will affect the dual values computed for presolved constraints.
See also https://groups.google.com/d/msg/ampl/ERJ8nF_LnNU/75yWK9deBjUJ
for me "option show_boundtol 0;" worked. You can try this. By default it is "option show_boundtol 1;".
You can read about it here (http://ftp.icm.edu.pl/packages/netlib/ampl/changes)

making logback filename in TimeBasedRollingPolicy use leading 0s for %i

Is there any way to make logback create TimeBasedRollingPolicy file names that use leading 0s for %i. Here's an excerpt from the logback.xml file
...
<rollingPolicy class="ch.quos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/foo_%d{yyyyMMdd}-%i.log</fileNamePattern>
...
</rollingPolicy>
...
This creates files named like this foo_20130501-0.log, foo_20130501-1.log, ... foo_20130501-9.log, foo_20130501-10.log, ...
Instead, I would like the files named like this: foo_20130501-000.log, foo_20130501-001.log, ... foo_20130501-009.log, foo_20130501-010.log, ...
No, as of 2013-05-01, this is not possible with logback version 1.0.12 or earlier. Please create a jira issue requesting this feature.