How to share Eclipse configuration over different workspaces

Sharing eclipse specific settings across workspaces: Go to ${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings Copy everything under the above directory to ${new_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings This is going to make sure that the ${new_workspace} is having the same configuration as the ${old_workspace} Update in case of any issues.

How to change filehandle with Python logging on the fly with different classes and imports

Indeed, logging.basicConfig does nothing if a handler has been set up already: This function does nothing if the root logger already has handlers configured, unless the keyword argument force is set to True. You’ll need to either add force=True (requires Python 3.8 or newer), or, alternatively, replace the current handler on the root logger: import … Read more

How to avoid storing passwords in the clear for tomcat’s server.xml Resource definition of a DataSource?

As said before encrypting passwords is just moving the problem somewhere else. Anyway, it’s quite simple. Just write a class with static fields for your secret key and so on, and static methods to encrypt, decrypt your passwords. Encrypt your password in Tomcat’s configuration file (server.xml or yourapp.xml…) using this class. And to decrypt the … Read more

.Net app.config in library project

By default, there is only 1 “.config” file for a running application. It is the “.config” file associated with the EXE that started the program. You should probably copy the config values from the DLL’s config file into the console app’s config file. If you really want to keep them separate then you can’t use … Read more

How to write to the main exe’s .config userSettings section?

After some research I came up with this solution. It is a bit low level, but still goes through the .NET configuration API without having to manually parse the .config file. static void SaveUserSettingDefault(string clientSectionName, string settingName, object settingValue) { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // find section group ConfigurationSectionGroup group = config.SectionGroups[@”userSettings”]; if (group == … Read more

VS2005 C# Programmatically change connection string contained in app.config

Had to do this exact thing. This is the code that worked for me: var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionStringsSection = (ConnectionStringsSection)config.GetSection(“connectionStrings”); connectionStringsSection.ConnectionStrings[“Blah”].ConnectionString = “Data Source=blah;Initial Catalog=blah;UID=blah;password=blah”; config.Save(); ConfigurationManager.RefreshSection(“connectionStrings”);

Specify the application base path in ConfigurationBuilder in beta8

If we look at the source code of ConfigurationBuilder, we can see that the constructor no longer accepts a string representing the application base path. In stead, we have to use the SetBasePath() extension method on the IConfigurationBuilder interface to specify it: public Startup(IApplicationEnvironment appEnv) { var configurationBuilder = new ConfigurationBuilder() .SetBasePath(appEnv.ApplicationBasePath) .AddJsonFile(“config.json”) .AddEnvironmentVariables(); Configuration … Read more