Showing posts with label source files. Show all posts
Showing posts with label source files. Show all posts

Tuesday, April 03, 2012

Log4Net Configuration trouble

Recently i had some log4net configuration trouble

log4net has a feature in its configuration file where it tries to read Configuration name tags from the config file and locates them as writable properties on the class (Logger/Appender etc..) using reflection.

the function used is

protected void log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElementelement,objecttarget)
this function locates the property for you and updates its data if it finds it if not it fills your screen and logs with garbage until its fixed!
It will even locate the property if you write it in the wrong case.
However, it does not help you in locating your error. I do not expect log4net developers to write a “google-style” {did you mean xxx} function. But I think they could have a better log response
instead of a bland
LogLog.Error(declaringType, "XmlHierarchyConfigurator: Cannot find Property [" + name + "] to set object on [" + target.ToString() + "]");


It would be nicer (I think) to write something like

LogLog.Error(declaringType,
string.Format(
"{2}Reflection did not find Writeable Property/Field named [{0}]. Check ObjectBrowser for class {1} and see what writable attributes/fields exist. maybe misspelled? You XML Error is located in {3}"
, name, target.ToString(), "XmlHierarchyConfigurator", element.ParentNode.InnerXml)
);

which would give something like

XmlHierarchyConfiguratorReflection did not find Writeable Property/Field named [hello]. Check ObjectBrowser for object log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl and see what writable attributes/fields exist. maybe misspelled? You XML Error is located in <level value=\"Info\" /><hello value=\"4\" /><appender-ref ref=\"LogFileAppender\" /><appender-ref ref=\"RSLogFileAppenderInfo\" /><appender-ref ref=\"RSLogFileAppenderFatal\" />"


for the error of adding the field “hello” to the XML.


This is at the very least a more helpful comment.


At least now I know what to look for. any attribute in log4nt configuration must have a real writeable field/property in the log4net object hierarchy.


good to know.


 


Mickey Perlstein

Thursday, December 08, 2011

Android Source Files

 

for some reason, the open-source project Google setup for android with all the Git’s and Repos and stuff is very well mainained but requires a degree in particle physics to understand.

This is especially true, if you’re just trying to look under the hood of android and not interested in joining the project per-say or  uploading stuff of your own to a Git repository.

I come from Windows and am unused to becoming an IT specialist to install and use development software.

looking around different blogs and sites I finally found a likeminded individual interested in spreading the joy of SIMPLE and EASY rather than COMPLEX and REQUIRES HOURS OF UNDERSTANDING to do android things.

I want to develop for android, not be part of a complex Operating System’s development team (at least not for now).

I found a blogger who has likeminded views on the subject.

http://mobilebytes.wordpress.com/2010/06/30/classes-source-for-eclipse/

He has downloaded, stripped, mapped, vm’s and refitted the sources for android classes ready for Eclipse.

I uploaded them to megaupoad as well to lower this bloggers bandwidth problems (in case he pays for them)

and here they are:

Android version source megaupload URL I uploaded it to
1.5 r3 http://www.megaupload.com/?d=OL71VL2F
1.6 r2 http://www.megaupload.com/?d=B5F0R1AV
2.01 r1 http://www.megaupload.com/?d=MIJOHYYI
2.1 r1 http://www.megaupload.com/?d=93048HL0
2.2 froyo http://www.megaupload.com/?d=UJRSNLHN

 

In case you don’t know how to wire this up:

Step 1

Download the source codes into a directory such as c:\android\android-sdk-source\

SNAGHTML498a857

Step 2

1) open eclipse, open a project you wish to view the source of:

 

Right click on android.jar – select image

2) Select properties (last one on the context menu) or press Alt-Enter

3) In the window that comes up, under Java source Attachment select External file, then find the source file you downloaded in my case C:/Android/android-sdk-sources/android-sdk-1.6_r2-src.jar

image

4) click Open on the Windows Folder

5) and OK on the eclipse, and you should be all sourced up.

usage:

Click F3 on an android class such as BroadcastReceiver.class and you will see the source code.

image

Word of warning to the Debuggers out there.

YOUR USE OF ANDROID SOURCES and Versionage does not mean the EMULATOR is using the same version - if your app is for android 1.6 (as most should be) and your emulator is 2.2, the source you should attach is 2.2 as the emulator works under 2.2 and not 1.6

make sense?

Good luck

Mickey Perlstein