Error when starting the Application Insights Agent for Java - azure-application-insights

I have configured my environment as described in this link for the Application Insights Agent for Java: https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-agent
I configure an environment variable so that the Java Options are set with the option "-javaagent:" set to the directory where the agent jar file is located and the associated AI-Agent.xml file. I continue to get a startup error:
"[Fatal Error] AI-Agent.xml:1:10: The processing instruction target matching [xX][mM][lL]" is not allowed."
The configuration file contains the default values from the above link. I have also tried other times where I have removed everything except for the outer tags but still get the same error so I do not believe the config file is the issue. Does anyone know what this message means?

Related

could not load file or assembly Nlog.web.aspnetcore or one of its dependencies

I am getting the yellow screen of death for my asp.net application which has the NLog implementation enabled. The error is "Could not load file or assembly NLog.Web.AspNetCore or one of its dependencies" while initializing the logger. I followed all basic setup rules for the logging from NLog in my asp.net application and it still fails to work. The log files are not written too. I am confused how to troubleshoot further.
Here are the things I did but no luck,
Enabled exceptions for NLog = > Thus I found that Logger has a problem loading NLog.Web.AspNetCore. It says the system cannot find the file specified.
The extensions section in the Nlog config was there by default and it contains NLog.Web.AspNetCore however my application isn't based on asp.net core.
the file path of the log is set as name="MyLog" type="File" fileName="log.txt" along with layout and createDirs = true in the target section.
Rules of the log is also defined. logger name = "*" minlevel=trace writeTo="MyLog".
Some how I couldn't get this working for past 2 days. Please guide me with some hints to resolve this problem. Appreciate your time to help!
Many thanks.
If the following is true:
however my application isn't based on asp.net core.
Then you should stop your attempts in trying to load NLog.Web.AspNetCore (Remove from it from <extensions>). And remove any references to layout-renderers that begins with ${aspnet-

asp.net error “The type 'typeName' exists in both ”temp1.dll“ and ”temp2.dll"

When I build a web site I haven't got errors, but when I try to publish site the error appears:
Type 'AttachmentsControl' exists in both в 'c:\Users\userName\AppData\Local\Temp\Temporary ASP.NET Files\web.ui.application\8c85983a\5425041a\App_Web_mivbsgll.dll' and 'c:\Users\userName\AppData\Local\Temp\Temporary ASP.NET Files\web.ui.application\8c85983a\5425041a\App_Web_dhvduebi.dll'
I tried to add the batch="false" attribute to the "compilation" element of the web.config file, but this didn't help.
Also I tried to rename one class, but in this case another error appears:
Server Error in '/projectName' Application.
Thread was being aborted.
Can anybody help me?
P.S.: the most strangest thing is that I get this project from MS TFS, my colleague who add this project to TFS publish this site without errors.
Most probably the reason could be you are uploading the source files along with compiled published output and at the same time the source files are modified.
When you see this error, what asp.net is trying to do is, compile the files and create the application and the result is, you have two type declaration of same name, one in the dll and one in the source.
Try to delete the dll file you have uploaded (from the bin directory), it should resolve the issue.

Log4cxx multiple output

I have log4cxx implementation in utility.dll. This dll is used by application1.dll and application2.dll
Application1 defines log file name as "c:\application1\applog.log"; Application2 defines log file name as "c:\application2\applog.log".
If I run both the applications seperately, logs are created in the corresponding files properly. If I try to run both the applications simultaneously the logs are created in latest opened application's log file.
I have opened application1 first logs are created in "application1\applog.log" file. At same time I opened Application2. Now both application's logs are appended in "application2\applog.log"
Note: Both of my applications are dlls acting like a drivers) Both are acting as a seperate application I need logs to be in different output files. Both dlls will run under same exe.
How to make the the same log4cxx implementation to log in different log files per application?
I had a similar situation where my app and dll were logging to the same file. This is just an educated guess, but try changing the name of the logger in the dlls and app.
// in application1.dll
const log4cxx::LoggerPtr logger1 log4cxx::Logger::getLogger("ABC"));
log4cxx::PropertyConfigurator::configure("./application1.config");
// in application2.dll
const log4cxx::LoggerPtr logger2 log4cxx::Logger::getLogger("ABC"));
log4cxx::PropertyConfigurator::configure("./application2.config");
Assuming you are using a canned configuration. applicagtion1.config and application2.config could be identical except for the log4j.appender.File.File= line
in application1.config
log4j.appender.File.File=logs/application1.logs
and in application2.config
log4j.appender.File.File=logs/application2.logs

How to Configure Test Deployment with the file LocalTestRun.testrunconfig?

First of all sorry if the question is not very clear.
I am learning nHibernate from the summerofnhibernate.com, in the first chapter when I run a test project, I get the following error: Test method TestProject1.NHibernateDataProviderTestTest.CanGetCustomerByIdTest threw exception: NHibernate.HibernateException: problem parsing configuration : System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies;PrivateAssemblies\hibernate.cfg.xml'.
I have googled the problem, and the search says that the VS 2008 path is wrong(buggy), to place hibernate.cfg.xml in test project and adding the attribute: [TestMethod(), DeploymentItem("hibernate.cfg.xml")]
After having done this I still get the same problem.
But when I use Visual Studio 2010 I get the following error:
Test method TestProject1.NHibernateDataProviderTestTest.CanGetCustomerByIdTest threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
looks like 2 different problems.
For the first place nhibernate.cfg.xml in the Project and give the path to new Configuration("Path to hibernate.cfg.xml") somewhere in the testsetup.
The Second looks like the getmethod returns null because it cant finde the Customer with given id in the database. If you use SQLite inMemory a typical captcha is, that each new Connection points to a different Database -> Open Sessions with sf.OpenSession(theOneConnection) or Session.Clear() instead of creating a new one.
Hope it helps
Basically , (depends on your question : How to Configure Test Deployment with the file LocalTestRun.testrunconfig?)
Here is the way that you can follow:
To select files or folders to deploy, in run configuration
In Solution Explorer, under Solution Items, double-click the run configuration file that you want to edit.
A dialog box that has a name such as .testrunconfig appears.
Click Deployment.
Under Additional files or directories to deploy, specify additional files or folders to be copied.
To do this,
click Add file to select files; this opens the Add Deployment Files dialog box.
You can also click Add Directory to select folders by using the Add Deployment Directory dialog box.
In the .testrunconfig dialog box, click Save and then click OK.
These deployment items will be copied to the deployment folder whenever this run configuration file is active.
Hope this will help.

Log4j in Websphere

I recently take over a web application project using websphere and log4j running under AIX. To create a development environment, I setup all the components in windows, using eclipse to compile a WAR file and deploy it.
All is working fine except that log file is not created.
I changed the log file in log4j.properties from something like in below and and give everyone full access permission to the directory:
log4j.appender.F1.File=/abc/def/logs/admin.log
to
log4j.appender.F1.File=c:/logs/admin.log
What else can I check?
I create a simple standalone testapp which use the same log4j.properties and it can create the log file, but when the servlet deployed to websphere, it doesn't work. Please help! Thanks!
Ok, I think this article should help you. It seems that WebSphere CE uses log4j by default and controls it with a global properties file. There is a section on how to use application-specific properties files.
Here is what I try and do to troubleshoot similar issues.
Turn on log4j debugging to see where it actually picks up the file from. You need evidence of which file is picked up (so turning the debug on is a worthwhile activity) This provides you information with what log4j is trying to do to locate the configuration file.
-Dlog4j.debug=true
I would not hardcode the log4j location in the code. Instead I
would use the log4j.configuration System property and state that in
the JVM arguments. This way even I don't need to touch my code.
-Dlog4j.configuration=file:///home/manglu/log4j.properties
I would use this approach irrespective of the runtime server that I use (be it Tomcat or WAS CE or WAS)
Hope this helps
I suggest you use environment variables set on your server like this :
You must access the admin console of your server.
Under custom properties
Server_path=/abc/def/logs
In your log4j, use this : {$server_path}/log.txt
Make sure the user running the app has access to that directory.

Resources