log4net log message does not contain method name - asp.net-core

I am trying to include the method name %method in log messages when using log4net. However, if I look at the log output it only shows a ? where method name should be.
I know in reading the log4net docs that this is only available with System.Diagnostics.StackTrace and this should only be used in development and not release builds.
Trying to make this work in a .NET Core application using the Microsoft.Extensions.Logging.Log4Net.AspNetCore
and the call to .AddLog4Net(); in Startup
Here is the conversionPattern for the RollingFileAppender
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
I have put together a github repository with bare bone example of what I'm trying to get at. If you run the project you see the log file output does not contain method information.
Repository available at log4net-netcore-example
In reviewing various SO articles, I've not found the solution to this yet. I'm assuming I'm missing a configuration or maybe a nuget package required to make this work.
Appreciate any insights anyone can provide.

Related

How to fix, blank screen after deployment of war file

I work still view month on a project with RapidClipse 4.0
I deployed on the production server several versions of the project war files. Everything worked fine.
After the last deployment I got a blank screen after loading the application URL
For the server I use a docker container with following setting:
Apache Tomcat/8.5.43, JVM: 1.8.0_222-b10, 3.10.105, amd64
My first thought was: "ok you did something wrong in your code.. turn back and every thing is fine.... :-((
It wasn't !!
I used several versions which runs fine befor.
I stopped the application, redeployed it and deleted it.
Then I deployed an older version....and once again a version older..a.s.o
Non of the versions which worked fine befor did work again.
I got every time the same result: after loading the application a blank white screen.
So far so bad:
I tried to look into ../conf/server.xml if deployment parameter is set correctly:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
looked fine!
I enhanced the cache by:
$CATALINA_BASE/conf/context.xml added following code:
<Resources cachingAllowed="true" cacheMaxSize="100000" />
also without success.
I tried to look in catalina.out: There is still nothing helpfull:
14-Aug-2019 20:29:21.087 INFO [http-nio-8080-exec-6] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/RC_07.war]
14-Aug-2019 20:29:31.190 INFO [http-nio-8080-exec-6] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/RC_07.war] has finished in [10,102] ms
after debug in browser I got following:
257ms Processing time was 134ms
257msReferenced paintables: 6
283msEstablishing push connection
300msCould not load theme from http://myIP:8888/RC_07/VAADIN/themes//styles.css?v=7.7.13
310msPush connection established using long-polling
I searched also in the history of the docker container an found that this problem (300ms....) still persists from beginning, over all versions I deployed before.
Out of this, I assume, that this could not be the reason, too.
Or am I wrong?
I searched around this VAADIN Problem and found a lot, but I was not able to solve it. The styles.css file are still in place on the server.
I am wondering on ..../VAADIN/themes//styles.css...
the double slash in error message.
But in my code I couldn't find similar.
Also the buildpath in eclipse includes the folder structure like expected.
Now I am at the end!
I am confused, how I should go ahead to figure out the reason for this behavior, or much better to fix it.
Any idea/ help would be welcome!!
Thank you in advance
rgds
OpaHeinz
After long research, togehter with RapidClipse support we found the solution.
I had two issues:
1) unknown how, we assume, that there was an error in the MainUI xml file.
After resetting with and high of view and layout, and turning back to setting before,
the page elements were visible again in design view.
2) there is a parameter for the theme under MainUI properties - misc -
This parameter was set, but without content. This results in a code line: this.setTheme("");
After resetting this, a deployment was possible like before.
Everything is fine now.
Thanks again to RapidClipse support.

Defining userDao in AppFuse 3.5

I am following the tutorials on http://appfuse.org/display/APF/Tutorials and I am confused on the "Register a personDao bean definition" section.
If it is necessary to register dao beans in the applicationContext.xml (or in applicationContext-dao.xml as I have seen it in an older version of an AppFuse application that I've been working with)... why is it not necessary to also register the userDao bean in the same way?
I have an alternate motive for asking this question as well...
I've been trying to port an application from an older version of the AppFuse framework (same application I mentioned above). But when I attempt to navigate to any page other than the ones that come with the original code, I get "Page not found" errors. Which is why I have gone back to the tutorials... I really want to get a handle on this since I am taking over someone else's code and they are no longer available for comment.
In addition, when adding the personDao to applicationContext.xml, IDEA complains "Required properties missing: 'sessionFactory'". When adding the line: , it then complains "Cannot resolve bean 'sessionFactory'"
It isn't necessary to register the userDao bean because it's already been done for you. The applicationContext-dao.xml file is included in the appfuse-hibernate (or appfuse-jpa) JAR file and it's imported into tests and in web.xml.
In it, it has the following:
<!-- Activates scanning of #Repository -->
<context:component-scan base-package="org.appfuse.dao"/>
You can see the file online at http://source.appfuse.org/browse/~br=release-3.5.0/appfuse/data/hibernate/src/main/resources/applicationContext-dao.xml?r=7486012b603604294be9384475b3750865c93bb6

ZF2 Doctrine ORM console application - error with execution as phar archive

I wrote simply ZF2 console based application. There is source: https://github.com/vagovszky/console. App is designed for import courses from XML into database. Everything works fine until app is packed into phar.
If I pack this application into phar archive (as described in README.md) and execute it, error occured:
Doctrine\ORM\Mapping\MappingException Class "Database\Entity\Ligues" is not a valid entity or mapped super class.
I do not know how fix this issue, thanks for help.
This is a known issue: Doctrine's AnnotationReader isn't able to read annotations from classes within a PHAR package.

Configuring HTMLUNIT's logging level in Play-SBT

I'm trying to run Selenium tests using Play's built-in testing framework (TestServer, FakeApp, running() method) and running it through SBT, but the logging level for HTMLUNIT seems to be set at debug; causing a very large stack of useless messages.
I've already tried this:
Setting com.gargoylesoftware.htmlunit=ERROR in application.conf
Setting <logger name="com.gargoylesoftware.htmlunit" level="ERROR"/> in application-logger.xml
Doing the same thing as above but in test/resources/logback-test.xml
None of these seem to work. Looking at the log messages, it seems that it does understand that there is a logback-test.xml yet it just ignores it when it comes to HTMLUNIT.
Thanks
Figured it out. My problem was a lack of understanding of how play loads up xml files for logback.
There are 3 files that configure logback in play: logback.xml, application-logger.xml and application.conf. My issue was that I was declaring the levels in logback.xml (which loads before application-logger) but those settings were being overloaded by application-logger.
Putting the log levels on application-logger fixed the issue.

Team Build sends error when trying to compile a Structuremap method

I'm getting a strange error when trying to compile a solution that is using StructureMap on Team Build.
When I try to compile the solution locally on Visual Studio it works fine, but when trying to queue a new build in Team Build I get the following error:
Overload resolution failed because no accessible 'Use' can be called with these arguments:
The line of code that gets this error is the second one:
ForSingletonOf(Of ISessionFactory)().Use(NHibernateSessionFactory.SessionFactory)
Me.For(Of ISession)().lifecycleIs(New HybridLifecycle()).Use(Function(x) x.GetInstance(Of ISessionFactory)().OpenSession())
It's a standard registration for the NHibernate session, so I don't really get why this error pops up.
Thanks in advance for the clues.
Make sure you have the correct version of NHibernate on the build server, and that your hint paths are all appropriately set in your project file. We haven't had this specific issue (as we're not using NHibernate), but we've had weird issues like that being related to version mismatches of "infrastructure" DLLs between local and build.