• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Getting java.net.MalformedURLException while trying to initialize log4j in my java code

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am developing a batch file purely on core java and I am trying initialize log4j but I am getting below exception and code details are below. Could you please help me to resolve this?

Exception:

java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)


souce code to initialize log4j under start of the java main method:

URL configURL_Log4j_File;
try {
configURL_Log4j_File = new URL(ExposureConstants.getLog4jConfigPath());
System.out.println(configURL_Log4j_File);
PropertyConfigurator.configure(configURL_Log4j_File);

} catch (MalformedURLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}


ExposureConstants.java :

public final static String APP_CONFIG_FILES_PATH = System.getProperty("user.dir");
public static String LOG4J_FILE_PATH = "";
public static String getLog4jConfigPath()
{
if(APP_CONFIG_FILES_PATH.contains("workspace"))
{
LOG4J_FILE_PATH = "C:\\CPCRM_PROJECT\\workspace\\cpcrm_reort\\log4j_Exposures.properties";
}
return LOG4J_FILE_PATH;

}




 
author & internet detective
Posts: 40913
840
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java, files usually use the file protocol. Can you try it as file:///c:/...
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:In Java, files usually use the file protocol. Can you try it as file:///c:/...




Thanks for the response. Your suggestion worked in windows but how to handle this in unix? Could you please guide me?

Thanks
Nagaraj
 
reply
    Bookmark Topic Watch Topic
  • New Topic