NLog Email Target with High Priorty/Importance - email

I've recently changed the Email Target log level up one level from Error to Warn. This is to capture some important user actions which aren't Errors on an application level but user input errors, which I don't class as errors so have logged them as Warn.
So in my subject I've changed
subject="NLog Error Message from PoppyService on ${machinename}"
to
subject="NLog ${level} Message from PoppyService on ${machinename}"
so I get a different subject based on the log level, but is there a way to make the email High Importance for Error log level only? I imagine, I'll have to create a second mail target, one for Error and one for Warn, but I can't find how to change the priority of the email to High.
There isn't a way shown in http://nlog-project.org/wiki/Mail_target.

Unfortunately there are no way to do this in the current version of NLog, without creating a custom target.

Related

Azure WebJob Logging/Emailing

I've converted a console app into a scheduled WebJob. All is working well, but I'm having a little trouble figuring out how to accomplish the error logging/emailing I'd like to have.
1.) I am using Console.WriteLine and Console.Error.WriteLine to create log messages. I see these displayed in the portal when I go to WebJob Run Details. Is there any way to have these logs saved to files somewhere? I added my storage account connection string as AzureWebJobsDashboard and AzureWebJobsStorage. But this appears to have just created an "azure-webjobs-dashboard" blob container that only has a "version" file in it.
2.) Is there a way to get line numbers to show up for exceptions in the WebJob log?
3.) What is the best way to send emails from within the WebJob console app? For example, if a certain condition occurs, I may want to have it send me and/or someone else (depending on what the condition is) an email along with logging the condition using Console.WriteLine or Console.Error.WriteLine. I've seen info on triggering emails via a queue or triggering emails on job failure, but what is the best way to just send an email directly in your console app code when it's running as a WebJob?
How is your job being scheduled? It sounds like you're using the WebJobs SDK - are you using the TimerTrigger for scheduling (from the Extensions library)? That extensions library also contains a new SendGrid binding that you can use to send emails from your job functions. We plan on expanding on that to also facilitate failure notifications like you describe, but it's not there yet. Nothing stops you from building something yourself however, using the new JobHostConfiguration.Tracing.Trace to plug in your own TraceWriter that you can use to catch errors/warnings and act as you see fit. All of this is in the beta1 pre-release.
Using that approach of plugging in a custom TraceWriter, I've been thinking of writing one that allows you to specify an error threshold/sliding window, and if the error rate exceeds, an email or other notification will be sent. All the pieces are there for this, just haven't done it yet :)
Regarding logging, the job logs (including your Console.WriteLines) are actually written to disk in your Web App (details here). You should be able to see them if you browse your site log directory. However, if you're using the SDK and Dashboard, you can also use the TextWriter/TraceWriter bindings for logging. These logs will be written to your storage account and will show up in the Dashboard Functions page per invocation. Here's an example.
Logs to files: You can use a custom TraceWriter https://gist.github.com/aaronhoffman/3e319cf519eb8bf76c8f3e4fa6f1b4ae
Exception Stack Trace Line Numbers: You will need to make sure your project is built with debug info set to "full" (more info http://aaron-hoffman.blogspot.com/2016/07/get-line-numbers-in-exception-stack.html)
SendGrid, Amazon Simple Email Service (SES), etc.

How to make Bonita BPM to show an error?

I have an assignment where before I get a message from a server and tweet it, I have to check if an error occurs. If it does, it says that I have to "show with a human task an error message specifying a number and the error received. After that, the process ends".
In another part of the workflow I do check for errors but I'm not required to show anything, and frankly I do not understand how that would work, I believe my mistake is that I might be thinking too literally or too close to code showing errors and such.
Any help or place to look for information?
The answer to this question will vary depending on the edition of Bonita BPM that you are using.
With Community edition:
Note that error management will impact process design.
You can implement the following scenario:
retrieve the error (this can be done by using a custom connector output).
store the error details in a process variable.
have an exclusive gateway with a condition that branches to an optional human task that shows the error in a form.
With Performance edition:
There is a built in error management feature in Bonita BPM Portal. As an administrator you may review stack traces associated to connector execution failures, edit some settings and replay the connectors.
All of this is done without impacting the process design.

The queue does not exist or you do not have sufficient permissions to perform the operation

When I try to test the queue via the Message Bus. I've checked and permissions are set to full control for everyone. I use 'msmqmng.exe send' from a different machine to put a message onto the queue, it works and is absolutely the message I sent. So what other moving parts might I be missing???
I spent couple of days banging my head for this error, and the root cause was that the storage quota for MSMQ was exceeded! which doesn't seem related to the error message, which makes it a difficult cause to detect...
When sending a message to MSMQ, the sender server will use an outgoing queue located on the sender side, and this outgoing queue is using the storage on that sender server.
The MSMQ component has a maximum quota, defined in the MSMQ properties, and when this quota is exceeded, the above error message starts popping (that's why when you sent from another machine, it worked correctly, since the issue is with the sender not the receiver).
Resolution:
To change this quota, right click on Message Queuing (from Computer management if using Windows server 2003 for example) then properties... (I cannot post images since i am a new user), but in the properties window, you will find in the first tab an editable storage limit field.
To check the currently used storage on the server, open the path of the storage, and check its size: (open the storage tab in the same properties window, and get the path of the storage folder)
If the size of the quota is similar to the size of the storage folder, then this is the root cause of your issue.
If you dont have permission to increase this quota limit, you should have your user added to the "Security" tab in the message queuing properties window.
Hope this helps...
Please vote up if you agree in order for me to have some points and post images in my next answer... :-)
Setting up the queue in Server Manager, Message Queueing I neglected to add the data source name to the queue name. (queue_name_dsNAme) So from one side I was able to insert messages. However, from the Server Group, Message Bus, it automatically appends the data source to the queue to be tested. So, the queue really did not exist.
Turns out there's another twist... even after the naming convention was sorted out there was an application that knew of the queue and was reading from it. When the test message was sent the app grabbed it before the test mechanism had a chance to receive it back, which caused the timeouts. By enabling journaling the message gets put there and you can see what went through the queue. While all this may seem obvious... it pays to ask stupid questions.

Ejabberd server keeps logging me off and back on constantly

I'm building an iOS app, but the problem exists on all clients. iChat, Messages, Psi, etc. So because it exists on all clients I'm going to assume it's a server issue.
Has anyone ever experienced something like this? If so, what did you do to fix it? I'm sure it's some silly config setting or something but I simply can't figure this out. This is the only thing that looks like it might be related in ejabberd.log:
=ERROR REPORT==== 2012-09-05 12:07:12 ===
Mnesia(ejabberd#localhost): ** WARNING ** Mnesia is overloaded: {dump_log,
time_threshold}
Thanks in advance for any tips/pointers.
https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L936 seems to have already been patched. The config variable is called resource_conflict and the value you want is setresource.
The above warning is (probably) not related to the issue you are facing. These mnesia events usually happens when the transaction log needs to be dumped, but the previous transaction log dump hasn't finished yet.
Problem that you are facing needs to be debugged for which you can set {log_level, 5} inside ejabberd.cfg. This will enable debug logging for ejabberd. Then look into the logs to find any guesses on why this is happening for you. Also, come back and paste your log file details here, probably we will be able to help you further. I have never faced such non-sensical issues with ejabberd.
Update after log file attachment:
As Joe wrote below, this is indeed happening because of resource conflict. Two of your clients are trying to login with same resource value. But in an ideal world this shouldn't matter. Jabber servers SHOULD take care of this by appending or prepending custom value on top of resource value requested by the client.
For example, here is what gtalk (even facebook chat) servers will do:
SENT <iq xmlns="jabber:client" type="set" id="1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>jaxl#resource</resource></bind></iq>
RCVD <iq id="1" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>jabberxmpplibrary#gmail.com/jaxl#resou27F46704</jid></bind></iq>
As you can see my client requested to bind with resource value jaxl#resource but gtalk server actually bound my session with resource value jaxl#resou27F46704. In short, this is not a bug in your client but a bug in ejabberd.
To fix this you can do two things:
Resource value is probably hardcoded somewhere in your client configuration. Simply remove that. A good client will automatically take care of this by generating a random resource value at it's end.
Patch ejabberd to behave how gtalk server does (as shown above). This is the relevant section inside ejabberd_c2s.erl src which needs some tweaking. Also search for Replaced by new connection inside the c2s source file and you will understand what's going on.
This sounds like the "dueling resources" bug in your client. You may have two copies of your client running simultaneously using the same resource, and doing faulty auto-reconnect logic. When the second client logs in, the first client is booted offline with a conflict error. The first client logs back in, causing a conflict error on the second client. Loop.
Evidence for this is in your logfile, on line 3480:
D(<0.373.0>:ejabberd_c2s:1553) : Send XML on stream =
<<"<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
<text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
Replaced by new connection
</text>
</stream:error>">>

Periodical status messages by Jopr?

I'm evaluating Jopr 2.3.1 to monitor a JBoss 4.2.3 Application Server.
Jopr, based on the better known RHQ Project from Redhat, supports to send email notifications triggered by so called alerts. Alerts can be defined to react to certain changes of system parameter such as metrics (e.g. 'Active Thread Count', 'JVM Free Memory') or the availability (e.g. goes UP, goes DOWN) changes.
I'm now wondering if it's also possible to send a for instance weekly status report by email?
Just to make sure: This email notification is to be send periodically, indipendent of the regular alter notification, rather problems occured or not.
Many thanks in advance - every hint is appreciated
Tobias
RHQ 3 (anything Jopr related is old and outdated) has server side plugins.
They can be alert notification senders that let you e.g. connect to a trouble ticket system for alert notifications.
They can also be more generic and can be triggered periodically via an "internal cron". The latter may be what you want for report sending. In fact, Mazz has already written an example plugin generating a report on file system - you would only need to change the "write to disk" to "send email".
http://rhq-project.org/