NLog Layout with ${onexception} not displaying literal text - nlog

I have a Mail target to send an email for certain log entries. I would like the subject line to be prepended with "EXCEPTION THROWN:" (including the colon) if the log event includes an exception.
My subject line layout is:
${onexception:inner=EXCEPTION THROWN:}AppName Log Event
But the email sent has a subject line of:
AppName Log Event
None of the literal text within the ${onexception} layout renderer is included. And yes, I am sure an exception was passed. See below.
I thought maybe wrapping it in a literal renderer would help:
${onexception:inner=${literal:text=EXCEPTION THROWN:}}AppName Log Event
This gives me:
EXCEPTION THROWNAppName Log Event
That's better, but still missing the colon. It demonstrates that the issue isn't with a missing exception - the condition is being met because it's including at least some of the string. It's still stripping the colon, though.
Any ideas?

Ugh, nevermind. Posting here in case anyone else does what I did.
I needed to escape the ":". Once that was done, everything started showing up, even without using the ${literal} renderer:
${onexception:inner=EXCEPTION THROWN\:}AppName Log Event

Related

How Do I resolve "Illuminate\Queue\InvalidPayloadException: Unable to JSON encode payload. Error code: 5"

Trying out the queue system for a better user upload experience with Laravel-Excel.
.env was been changed from 'sync' to 'database' and migrations run. All the necessary use statements are in place yet the error above persists.
The exact error happens here:
Illuminate\Queue\Queue.php:97
$payload = json_encode($this->createPayloadArray($job, $queue, $data));
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidPayloadException(
If I drop ShouldQueue, the file imports perfectly in-session (large file so long wait period for user.)
I've read many stackoverflow, github etc comments on this but I don't have the technical skills to deep-dive to fix my particular situation (most of them speak of UTF-8 but I don't if that's an issue here; I changed the excel save format to UTF-8 but it didn't fix it.)
Ps. Whilst running the migration, I got the error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `jobs` add index `jobs_queue_index`(`queue`))
I bypassed by dropping the 'add index'; so my jobs table is not indexed on queue but I don't feel this is the cause.
One thing you can do when looking into json_encode() errors is use the json_last_error_msg() function, which will give you a bit more of a readable error message.
In your case you're getting a '5' back, which is the JSON_ERROR_UTF8 error code. The error message back for this is a slightly more informative one:
'Malformed UTF-8 characters, possibly incorrectly encoded'
So we know it's encountering non-UTF-8 characters, even though you're saving the file specifically with UTF-8 encoding. At first glance you might think you need to convert the encoding yourself in code (like this answer), but in this case, I don't think that'll help. For Laravel-Excel, this seems to be a limitation of trying to queue-read .xls files - from the Laravel-Excel docs:
You currently cannot queue xls imports. PhpSpreadsheet's Xls reader contains some non-utf8 characters, which makes it impossible to queue.
In this case you might be stuck with a slow, non-queueable option, or need to convert your spreadsheet into a queueable format e.g. .csv.
The key length error on running the migration is unrelated. It has been around for a while and is a side-effect of using an older version of MySQL/MariaDB. Check out this answer and the Laravel documentation around index lengths - you need to add this to your AppServiceProvider::boot() method:
Schema::defaultStringLength(191);

How to send "special characters" with Python Actions Send_keys?

I am making a code in Python 3.7 for testing an application in Appium.
I am trying to send a text in an input field of an application. The text is in French with special characters (é, è, à, etc.).
My code managed to type character by character, one by one, but when it arrives to a special character with accent "é", it bugs! Here is error message:
Encountered internal error running command: io.appium.uiautomator2.common.exceptions.InvalidArgumentException: KeyCharacterMap.getEvents is unable to synthesize KeyEvent sequence out of '233' key code. Consider applying a patch to UiAutomator2 server code or try to synthesize the necessary key event(s) for it manually
I read the doc and forum and I added this capability:
desired_caps['unicodeKeyboard'] ='true'
But it didn't change anything. I still have same issue.
Try sending keys like:
self.driver.find_element().send_keys(u'éèà')
Change true to True
desired_caps['unicodeKeyboard'] ='True'
And this might help you
http://appium.io/docs/en/writing-running-appium/other/unicode/

logstash custom log that has xml tags inside

I have a custom log file that has plain text as well as xml tags. How do i capture these in separate fields. Here is how it looks like:
1/10/2017 4:16:35 AM :
Error thrown is:
No Error
Request sent is:
SCEO415154712
Response received is:
SCEO4151547trueTBAfalse7169-1TBAfalse2389-1
1/10/2017 4:16:35 AM :
Error thrown is:
No Error
*************************************************************************
Request sent is:
<InventoryMgmtRequest xmlns="http://www.af.com/Ecommerce/Worldwide/AvailabilityService/Schemas/InventoryMgmtRequest"><ns0:MsgHeader MessageType="FIXORD" MsgDate="10.01.2017 04:16:32" SystemOfOrigin="ISCS_DE" CommunityID="SG888" xmlns:ns0="http://www.av.com/Ecommerce/Worldwide/AvailabilityService/Schemas/InventoryMgmtRequest"><ns0:OrderID>SCEO4151547</ns0:OrderID><ns0:ReservationID></ns0:ReservationID><ns0:CRD></ns0:CRD></ns0:MsgHeader><ns0:MsgBody xmlns:ns0="http://www.ab.com/Ecommerce/Worldwide/AvailabilityService/Schemas/InventoryMgmtRequest"><ns0:Product Sku="CH562EE" Qty="1" IsExpress="false" IsTangible="true" Region="EMEA" Country="DE"><ns0:ProdType></ns0:ProdType><ns0:LineItemNum>1</ns0:LineItemNum><ns0:JCID></ns0:JCID></ns0:Product><ns0:Product Sku="CH563EE" Qty="1" IsExpress="false" IsTangible="true" Region="EMEA" Country="DE"><ns0:ProdType></ns0:ProdType><ns0:LineItemNum>2</ns0:LineItemNum><ns0:JCID></ns0:JCID></ns0:Product></ns0:MsgBody></InventoryMgmtRequest>
*************************************************************************
Response received is:
<ns0:InventoryMgmtResponse xmlns:ns0="http://www.ad.com/Ecommerce/Worldwide/AvailabilityService/Schemas/InventoryMgmtResponse"><ns0:MsgHeader MsgDate="10.01.2017 04:16:32" MessageType="FIXORD"><ns0:OrderID>SCEO4151547</ns0:OrderID><ns0:ReservationID /><ns0:ReadyToRelease>true</ns0:ReadyToRelease></ns0:MsgHeader><ns0:MsgBody><ns0:Product SKU="CH562EE" LSPSKU="9432GFT" OutOfStock="false" FulfillmentSite="00ZF" SKUExist="true" Region="EMEA" Country="DE" IsTangible="true"><ns0:EDD>TBA</ns0:EDD><ns0:FutureUsed>false</ns0:FutureUsed><ns0:CurrentQty>7169</ns0:CurrentQty><ns0:FutureQty>-1</ns0:FutureQty></ns0:Product><ns0:Product SKU="CH563EE" LSPSKU="9432GFU" OutOfStock="false" FulfillmentSite="00ZF" SKUExist="true" Region="EMEA" Country="DE" IsTangible="true"><ns0:EDD>TBA</ns0:EDD><ns0:FutureUsed>false</ns0:FutureUsed><ns0:CurrentQty>2389</ns0:CurrentQty><ns0:FutureQty>-1</ns0:FutureQty></ns0:Product></ns0:MsgBody></ns0:InventoryMgmtResponse>
*************************************************************************
Also I don't want to capture the line separators (line full of **** at the end) in my grok fields.
There is no simple answer here I'm afraid. Logstash and other log processing tools works line by line, each line is an event. If your events span more than one line you can use the multiline codec, which is pretty powerful, but in my experience you are better off trying to get the logs on to single lines at source, this makes it so much easier to write a pattern and get the process working reliably.
The issues you have here are many, but if, for example, one of your messages (sent via TCP) is retransmitted for some reason or simply (sent via UDP) lost, your pattern will break as part of the message that logstash is expecting is not there.
The best thing you can do in my opinion is to try and change the logging process to save to a file as a single line per event. Most logging tools should allow this with the right config options. Ideally, get your application to log in json format, (assuming you're processing logs to save them in elasticsearch) this would involve the lowest overhead on the logstash server to process these logs (as elasticsearch saves them in json format). All you would then need to do is pass each event/log line to the json filter and the fields are generated by the names given to it by your application.

Unexpected ellipsis in syslog or splunk message

I am logging data to Splunk via log4j and a SyslogAppender. Sometimes the information shows up in Splunk with ellipsis (...) instead of the actual text with some odd spacing. When I log the same event to a RollingFileAppender, it logs normally. Would anyone know why this is happening and how to resolve it?
Thank you!
Example:
InboundTxnDate: 20130926 16:53:14:475
Out...
...boundTxnTypeCode: UNK
This is how syslog appenders work, they split log message, if it is bigger than 1019 bytes. When log message is split, this message will end with ellipsis and next message starts with ellipsis. Limit of message (1019 bytes) is hardcoded and cannot be changed by no configuration in log4j. Look at RFC 3164 and see source code of SyslogAppender
Would anyone know why this is happening
Ondřej Benkovský answered that very well and I have nothing to add.
how to resolve it?
If the split lines are part of the same event in Splunk, you can join them by editing $SPLUNK_HOME/etc/system/local/props.conf and adding a stanza like this:
[<spec>]
SEDCMD-join_log4j_syslog_lines=s/\.\.\.[\r\n]+\.\.\.//g
That will join the lines at index time and remove the ellipses.
Note that you'll need to change <spec> as detailed in the document for props.conf.
You can use the regex search command to make sure it's working:
| regex "\.\.\.[\r\n]+\.\.\."

Resetting textArea length JavaFX

I wrote server in C and client in Java. I used JavaFX for GUI. Everything works except that sometimes I get exceptions when textArea gets filled and receives more data before it gets reseted (probably cause of parallel threading). Actually there are 3 cases which occur "randomly":
1) Stucks/hangs and no exceptions are thrown.
2) NullPointerException (about Line Padding and Content Bounds [there's nowhere my code mentioned]).
3) IllegalArgumentException: Both width and height must be >= 0.
4) Exception about String text bounds.
Here's the code if it helps:
if(textArea.getLength() > 500) // I tried with > 2000, similar situations occur
textArea.setText("");
command = textField.getText();
out.println(command); // out to socket
textField.setText("");
Btw, this GUI should represent basic Linux shell, so textArea should sometimes be able to receive large amount of data (such as netstat command).
Thanks!
It is an exact dublicate of your previous question but with more info, so not going to vote for closing. I asked you to post exception stacktrace in that previous question, but you mentioned there is no your code related lines in stacktrace, hence I also presume like you that it is a bug of textArea. So I suggest to try to use another component, for example a big Label with white background :), if it is solely for displaying purposes.

Resources