Log4j2 one file per user session - log4j2

In my vaadin application, I'd like to create one log file per user session. I started to create a customer file appender but then decided to investigate on ThreadContexts a bit more. I now store the user's uid inside the ThreadContext, which works fine within my PatternLayout (%X{uid}), but unfortunately not inside the FileAppender (maybe I was a bit naive).
Which way would you go for something like this? Simply put, I'd like to get this result for the time being:
User not logged in -> filename=debug.log
User logged in -> filename=[username]_debug.log
Any ideas or pointers highly appreciated!

Problem solved and lessons learned:
To write to different log files, I needed Routers, as described in the FAQ. No clue why I didn't come across this while googling.
There's no need for a custom appender to solve this problem.
Log4j2 is very, very picky about directories not being writable. If this occurs, scroll up in the stacktrace: ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender. You'll find the culprit, google won't.
As well, Log4j2 cares in which order the appenders appear. It's stated multiple times in the FAQ and in the appender docs, still I overread it multiple times.

Related

Quickbooks web connector OwnerID/FileID usage

I would like to know what exactly does OwnerID/FileID in a QWC file signify. I went through the QBWC_proguide but still it is somewhat unclear to me. I am new to this so please can somebody elaborate this. Thanks in advance!
I would like to know what exactly does OwnerID/FileID in a QWC file signify.
Nothing. :-/
They really serve no purpose except to make sure that you can't load the same .QWC file twice. You can safely make up these values (they have to be valid GUID values) and even change them if you need to legitimately re-load a .QWC file and QuickBooks won't let you.
Just to add to Keith's answer, while it does prevent you from adding the same company connector config twice, I believe you can also pass OwnerID to the CompanyRq query to get back the FileId, which is unique for each company and can be used for multi-connect
See https://stackoverflow.com/a/65679466/2807183 for more details

Is there a way to set Event ID on EventLog sink (in Serilog)?

I took a look at Serilog.Sinks.EventLog at Github and noticed there doesn't seem to be a way to set the Event ID of the logged event (example IDs here).
Would there exist a way to modify the sink so that it'd be possible? Perhaps with some kind of specially formatted message? I don't know if I should put this here or on Github, I'll try here first. :)
There isn't a mechanism currently for this - designing one seems tricky (but ultimately it'd be a great addition to the project!)

GADS EntityExists errors

We use both the Java API and GADS. GADS has a varying list of "EntityExists(1300) - EntityExists(1300):" errors(which are correct) almost every run now, for the past few weeks.
Any word on what has changed, what we need to change, or when a fix will come?
Thanks
You should be looking at your GADS configuration and trying to determine why GADS wants to create users that already exist in Google. Most often, this is because the users are excluded under the Google configuration so GADS can't see them and wants to create them.
Jay
One thing I would suggest the admin to do is to flush the GADS cache to see if he is still receiving the 1300 error. You can do that by simply removing the cache folder (Sync State).

What is a good Rails logging solution?

I am looking for a solution that will allow me to do advanced logging:
Unlimited log size
Ability to filter by priorities (debug/info/error)
Ability to filter by models/custom- tag
Ability to filter by user-sessions (see only errors for a specific session)
Should be able to work on Heroku
*Optional: Set rules to email/sms on certain high-priority errors
Either a tool that works with files and can easily diesct them, or a DB backed log storage.
Any suggestions are most welcome
Try Log4r first; if it doesn't do exactly what you need, it's pretty tweakable.

A public action method pagerror.gif / refresh.gif could not be found on controller - who is calling that gif?

Hello stackoverflow world.
(This is the first time I actually post a question here. Exciting)
A while ago I inherited a 2 year old MVC website from one of the teams within my corporation. I know most the ins and outs of this solution now but there is something strange cropping up in my error logs which I do not understand.
Every now and then I will get an error messages like this one:
A public action method 'xyz.gif' could not be found on controller MyNamespace.MyController
What I don't understand is WHY is this action (a gif image) being called in the first place?
I've seen 2 different gifs in the error logs pageerror.gif and refresh.gif
As this is an inherited solution I double checked everything and made sure that there are in fact no images like that in the project and no reference anywhere even to those words in the controllers, views, style-sheets or even in the source of pages within the same controller.
I seriously doubt that the users are playing around with the URLs and adding random gif names to them to see what happens.
I'm all out of ideas. Anyone out there who can suggest more places to look for the culprit?
Ta!
As Tchami pointed out in a comment on the original question, this is related to Internet Explorer's default error pages.
As I have set up custom error pages I believe this is either due to an internal server error or possibly somehow an action cancel error from the client side, i.e. client side error. I can't be 100% at this point.
The question is not fully answered but I mostly know what the cause is now.
From my point of view I've identified that I need to improve this ASP.NET MVC application so that
1) it doesn't report/log errors when someone tries to navigate to a non-existing controller action (e.g. these refresh.gif actions or any other)
and 2) handle it better for the client so that they don't end up clicking from one error page (default IE error page) to another (my custom error page when clicking the refresh icon on the IE page)
Another stackoverflow thread on a related topic:
Significance of 'pagerror.gif'?
(i can't post more links as I'm a new user)
CHEERS!
Solveig
Can you get the error to show up in the logs when you use the site yourself? If so, an add-in such as HttpWatch might help you see those .gif requests. If you can understand more about when they happen you might be able to figure out what's going on.
Pagerror.gif and refresh.gif are the default images from the IE browser/IIS server. Normally these images were shown when the browser is not able to retrieve the content.
If you see these errors in logs, then check the iis log to get more information.
For example,
IIS Log : look for this feild ,
cs(User-Agent)
compatible;+MSIE+6.0;+Windows
Here few things to be noted,
1)IE 6.0 apparently makes these requests on its own. I am not sure if any other IE 6+ Browser would show similar behavior.
2)All this will do is generates a 'bogus" event log entry because a null reference exception could happens when you request a non-existing GIF and that request goes through MVC pipeline.
3)Technically this simply can be ignored.
4) Optionally we could check if through routing we could stop “.gif” files from being processed by MVC Pipeline
All i would suggest is to handle it gracefully.
It may be difficult to pinpoint this, but my thought would be: check the javascript. If the image name is being dynamically generated somewhere, and then requested, a simple "find and replace" may miss the reference.

Resources