Set log level in environment variable for certain class in Spring - spring

In order to change log level, how env variable should be named for camel-cased class name?
For example I have my.package.MyClass:
export LOGGING_LEVEL_MY_PACKAGE=DEBUG works for the whole package well;
export LOGGING_LEVEL_MY_PACKAGE_MYCLASS=DEBUG does no effect
export LOGGING_LEVEL_MY_PACKAGE_MY_CLASS=DEBUG does no effect

Kudos to #sp00m!
export SPRING_APPLICATION_JSON='{"logging.level.my.package.MyClass": "DEBUG"}' solved the problem.
Reference to the Spring documentation

Related

Difference between using App::environment() vs app()->environment() vs config('app.env')

What's the difference between using App::environment() vs app()->environment() vs config('app.env') for checking environment? I assume the first two are the exact same thing, but what about those vs using config('app.env')?
What I can see the first two returns the whole service container instance, so is that worse for performance, but more secure or something? I'm reading that people recommend only using config() for your own config variables and for any other config variable that isn't the env one. Trying to figure out the reasoning.
Thanks!
App::environment() and app()->environment() are the exact same thing. The App facade and the app() helper function are both just shortcuts to access your application container.
In a web context (hitting your page from a browser), the App::environment() method and the config('app.env') function will return the same value.
In a cli context (artisan command, queued job, etc), the App::environment() method and the config('app.env') function could return different values. If the command being run is executed with the --env argument (ex: --env=testing), then the App::environment() method will return the actual detected environment ("testing"), whereas the config('app.env') function will continue to return the environment defined in your config file.
Two extra things to consider:
The environment() method is part of the public api. This means the only potential for breaking changes is on major releases. The app.env config value is not part of the public api. Laravel could change that at any point if they wanted to, even on a minor release. I doubt they ever would, but they've made no public promises.
The environment() method takes optional parameters to add a little syntactic sugar for testing your current environment. If you pass parameters, the method will return a boolean if you're in any of the supplied environments, instead of returning a string with the name of the current environment. The parameters are also treated as regex searches:
$isTesting = App::environment('test', 'testing', 'testarossa')
// or
$isTesting = App::environment('test*')
(the "*" is replaced with ".*" before the regex is run)
App::environment()
uses a Facade to get the environment, a facade of Illuminate\Foundation\Application.
app()
uses a helper function to return the \Illuminate\Container\Container::getInstance(). environment() in a method of this Container instance.
resolve()
is an alias for app() but expects a parameter e.g. resolve('config') or resolve(Application::class).
app()->make(Application::class)
Uses the Container to resolve the Application. This is equal to app(Application::class).
Config::get('app.env')
uses the Facade of \Illuminate\Config\Repository.
config('app.env')
uses a helper function to call app() to resolve the Config. You should only use env() when you are working in a config file located in config/.
public function __construct(Config $config)
uses dependency injection to resolve the Config.
Answer
When bootstrapping the Application, the config variables are loaded in this application using the Config.
So the Container uses Config to load the variables. Both are singletons, so calling them does not really affect the performance.
Which solution you choose sometimes depends on the use-case and mostly on preference.

How to define a second environment variable when the first one wasn't resolved in Spring?

Suppose I have configuration property called app.database.url. I need to search for the URL in two places, so I created resolvable property like that:
app.database.url=${APP_DATABASE_URL:DEFAULT_URL}
However instead of searching for the second environment variable with key DEFAULT_URL, spring resolves this property as a string with value DEFAULT_URL. Is is possible to tell spring that the second argument is also should be resolved by environment variables?
I think you can just use this:
app.database.url=${APP_DATABASE_URL:${DEFAULT_URL}}

Is there a class method or command to view the globals in .gof files? and how to extract the specific global within gof files

I want to get one global within .gof files, such as there is a file named export.gof(contains ^a,^b,^c),but i just want to get ^b, so how could i get that specific global with a command or classmethod. thank you!
Class %Global has method Import with GlobalList as the second argument, so, you can choose which globals to import or all. But, unfortunately, this argument ignored for GOF files. So, looks like, the only way is to import to another namespace or database (CACHETEMP for example), and merge particular global to the desired destination.

BASH: Looking for a way to import functions into the global scope from within a function

I'm writing a number of scripts that all depend on any number of "library" scripts.
My scripts are built together mainly with functions and in one of these functions named "init", I define the constants I need and try to import my libraries using "source". However, if I try to call one of the functions in the global scope or inside of another function it doens't seem to exist...
For declaring global variables there's "declare -g", is there an option like that for functions?
for reference, the scripts I'm writing reside here: Pegasus' Linux Administration Tools
Normally you can export function the same way as variables :
myfun() {
...
}
export -f myfun

How can I access a variable in another class?

I have a start screen with a log in button and a register button. Both lead to the same view controller, but its interface is based on a variable.
How can I make my startviewcontroller change this var, that can currently only be accessed from the mainviewcontroller?
I'm temped to say "just like you get access to any other classes properties. However, given you haven't shared any code it's may not be as simple. But in general you will need to have a pointer to an instance or shared instance (singleton) of your mainViewController. And of course those variables need to be public.
You would have to declare that variable global outside any class just below the import statements. You will be able to use the variable anywhere in your code.
import UIKit
var myGlobalVariable: Int

Resources