Logger configuration in Alfresco - alfresco

Is there a specific onfiguration for logger to print log.info() message ? I have action classes extended quatz class as shown below . but the log is not printing out in log file - alfresco.log . I can see system.out.println in tomcat log .
please let me know if there are any configuration changes reuired in log4j.properties ? I have kept all the config default didnt make any changes in log4j
following is screen shot of java class

first, please follow the rules how to ask in SO - otherwise your questions may be closed unresponded. Make sure you spent a minimum in research and learning from available how to's and explain what you found and tried so far. Don't expect busy people do your job ...
Alfresco's documentation is well indexed by Goolge: log4j.properties file
You need to overwriter the root loogging config
log4j.rootLogger=error
by enable the required log level for your package / class by
log4j.com.mycompany.mypackage.myclass=info

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-

How to integrate spring-security.xml file into spring boot ? using Annotation base only

I have searched and didn't find any helpful solution that's why i am going to post this question.
Actually i have spring boot project which is completely configure based upon 'Annotation'.
Now for some reason, i need to add spring-security into this project.
for that i am getting spring-security-XXX.xml file from other co-worker.
Now, i am thinking how can i wrote some Annotation which will automatically load that spring-serity-xxx.xml file into my current project environment without change any other part, so that i can achieve security feature as per spring-serity-xxx.xml file.
For example, #Configuration(classpath:spring-security-config.xml) something like, is it possible ?.
if it's possible then provide me completed list of configuration.
NOTE : security added to get OAuth integration.
Any Help Appreciate..!!
Use #ImportResource annotation.

Editing configuration files in Pax Exam

I am using Pax Exam to perform integration tests to my OSGi application. I have a configuration factory in which I specify the Karaf feature of my application to be installed in the test container and then modify some of a proerty of a .cfg file installed as part of my feature.
public class TestConfigurationFactory implements ConfigurationFactory {
#Override
public Option[] createConfiguration() {
return options(
karafDistributionConfiguration()
.frameworkUrl(
maven().groupId("org.apache.karaf")
.artifactId("apache-karaf")
.version("3.0.1").type("tar.gz"))
.unpackDirectory(new File("target/exam"))
.useDeployFolder(false),
keepRuntimeFolder(),
// Karaf (own) features.
KarafDistributionOption.features(
maven().groupId("org.apache.karaf.features")
.artifactId("standard").classifier("features")
.version("3.0.1").type("xml"), "scr"),
// CXF features.
KarafDistributionOption.features(maven()
.groupId("org.apache.cxf.karaf")
.artifactId("apache-cxf").version("2.7.9")
.classifier("features").type("xml")),
// Application features.
KarafDistributionOption.features(
maven().groupId("com.me.project")
.artifactId("my-karaf-features")
.version("1.0.0-SNAPSHOT")
.classifier("features").type("xml"), "my-feature"),
KarafDistributionOption.editConfigurationFilePut(
"etc/com.me.test.cfg", "key", "value"));
}
}
The property I specify in editConfigurationFilePut is modified correctly, however the rest of the .cfg file's properties are deleted. If I use the editConfigurationFilePut method to edit one of Karaf's configuration files it works as expected (just adds the new property without modifying the existing ones) so I am thinking that perhaps the problem is that Pax Exam attempts to modify the configuration before the .cfg file is installed by my feature and therefore creates a new file to put the property in. If this is the case is there some way to synchronise this process so that the .cfg file is edited only after the feature is properly installed?
There are a two different reasons for this.
1) The feature does get installed after the configfile has been "edited"
2) The feature only contains a config section and not a configfile section
I'd guess reason one is the most likely cause of this since it needs a running Karaf to install a feature through Pax Exam. So to work around reason one, replace the config with a config file present in your test project.
For reason two, make sure the feature actually does reference a config instead of a configuration admin config, or add your config to the configuration of the config-admin service. You can achieve this by injecting the ConfigAdmin service in your unit test and add your properties to the configuration pid.
EDIT:
Combine both solutions
Since because of 1) it takes longer for the config-file to be actually available, let config-admin service do the rest.
Make sure your test does retrieve the config-admin service either by injecting it or by waiting for it's availability.
Now within a #Before method make sure you wait till your config is complete and change it from there on. This way you don't need to duplicate the config files.

application looks for testNG.xml in wrong folder

Really hope i'll find an answer for this :-)
I started to write automated tests using webdriver+testNG and everything was fine. But now i created a new project and when i try to run it ( click on class->run as testNG test) i see an error message like:
An internal error occurred during: "Launching test".
java.io.FileNotFoundException: C:\workspace\OriginalProject\testng.xml (The system cannot find the file specified) .
But I dont use the OriginalProject at all right now.
Seems that that path is still present in some place!?
If I start by clicking the correct testng.xml file , it works fine !?
any idea?
Check your testng settings at window->preferences->testng. You might have specified your default testng XML there and all projects wud try to use the same one.

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